/*
 * Copyright 2016 LINE Corporation
 *
 * LINE Corporation licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.example.bot.spring.echo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.linecorp.bot.model.event.Event;
import com.linecorp.bot.model.event.MessageEvent;
import com.linecorp.bot.model.event.message.TextMessageContent;
import com.linecorp.bot.model.message.TextMessage;
import com.linecorp.bot.spring.boot.annotation.EventMapping;
import com.linecorp.bot.spring.boot.annotation.LineMessageHandler;


import java.net.*;
import java.io.*;


@SpringBootApplication
@LineMessageHandler
public class EchoApplication {
    public static void main(String[] args) {
        SpringApplication.run(EchoApplication.class, args);
    }
        
    @EventMapping
    public TextMessage handleTextMessageEvent(MessageEvent<TextMessageContent> event)  {
        System.out.println("event: " + event);
        //return new TextMessage("TEST: "+event.getMessage().getText());

        URL url = new URL("http://cdn.crunchify.com/wp-content/uploads/code/json.sample.txt");
        URLConnection con = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String l;
        while ((l=in.readLine())!=null) {
            System.out.println(l);
        }
        
       return new TextMessage("TEST: "+event.getMessage().getText());
 
        //URL website = new URL("http://cdn.crunchify.com/wp-content/uploads/code/json.sample.txt");
        
//        return new TextMessage(response.toString());
    }

    @EventMapping
    public void handleDefaultMessageEvent(Event event) {
        System.out.println("event: " + event);
    }
   

}

@@ -1140,31 +1140,108 @@
 ava.
-net.*;%0Aimport java.io.*
+io.BufferedReader;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.net.URL
 ;%0A%0A%0A
@@ -1662,16 +1662,34 @@
 xt());%0A%0A
+        try %7B%0A    
         
@@ -1718,65 +1718,24 @@
 p://
-cdn.crunchify.com/wp-content/uploads/code/json.sample.txt
+www.itcuties.com
 %22);%0A
@@ -1746,50 +1746,51 @@
     
+   
-URLConnection con = url.openConnection();%0A
+ InputStream is = url.openStream();%0A    
     
@@ -1808,18 +1808,18 @@
 dReader 
-in
+br
  = new B
@@ -1858,32 +1858,32 @@
 der(
-con.getInputStream()));%0A
+is));%0A             %0A    
     
@@ -1894,16 +1894,19 @@
 String l
+ine
 ;%0A      
@@ -1911,20 +1911,30 @@
     
+    
 while (
+ 
 (l
-=
 in
+e = br
 .rea
@@ -1945,17 +1945,17 @@
 e())
+ 
 !=
+ 
 null)
- %7B
 %0A   
@@ -1955,32 +1955,36 @@
 ll)%0A            
+    
 System.out.print
@@ -1987,16 +1987,19 @@
 rintln(l
+ine
 );%0A     
@@ -2005,88 +2005,153 @@
     
-%7D%0A
+ 
     
+%0A
     
-%0A
+ 
        
-return new TextMessage(%22TEST: %22+event.getMessage().getText());
+br.close();%0A            is.close();%0A             %0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D   
 %0A %0A 

Update EchoApplication.java