/*
 * 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 org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;


@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());

        String html = "http://cdn.crunchify.com/wp-content/uploads/code/json.sample.txt";
Document doc = Jsoup.parse(html); 
String text = doc.body().text(); // "An example link"
        
    //more code goes here
//}catch(MalformedURLException ex){

        return new TextMessage("TEST: "+text);
        //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);
    }
}

@@ -1127,163 +1127,238 @@
 r;%0A%0A
+%0A
 import 
-org.jsoup.Jsoup;%0Aimport org.jsoup.helper.Validate;%0Aimport org.jsoup.nodes.Document;%0Aimport org.jsoup.nodes.Element;%0Aimport org.jsoup.select.Elements
+java.io.BufferedReader;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.FileReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.net.URL;%0Aimport java.util.List;%0Aimport com.google.gson.Gson
 ;%0A%0A%0A
@@ -1790,250 +1790,385 @@
     
-String html = %22http://cdn.crunchify.com/wp-content/uploads/code/json.sample.txt%22;%0ADocument doc = Jsoup.parse(html); %0AString text = doc.body().text(); // %22An example link%22%0A        %0A    //more code goes here%0A//%7Dcatch(MalformedURLException ex)%7B%0A
+   Gson gson = new Gson();%0A%0A        String json = readUrl(%22http://api.wunderground.com/api/57dd9039b81a9c21/conditions/q/CA/San_Francisco.json%22);%0A%0A        Page page = gson.fromJson(json, Page.class);%0A%0A        System.out.println(page.description);%0A        System.out.println(page.language);%0A        System.out.println(page.link);%0A        System.out.println(page.title);%0A        
 %0A   
@@ -2511,10 +2511,876 @@
 ;%0A    %7D%0A
+       private static String readUrl(String urlString) throws Exception %7B%0A        BufferedReader reader = null;%0A        try %7B%0A            URL url = new URL(urlString);%0A            reader = new BufferedReader(new InputStreamReader(url.openStream()));%0A            StringBuffer buffer = new StringBuffer();%0A            int read;%0A            char%5B%5D chars = new char%5B1024%5D;%0A            while ((read = reader.read(chars)) != -1)%0A                buffer.append(chars, 0, read); %0A%0A            return buffer.toString();%0A        %7D finally %7B%0A            if (reader != null)%0A                reader.close();%0A        %7D%0A%0A    %7D%0A%0A    static class Page %7B%0A        String title;%0A        String link;%0A        String description;%0A        String language;%0A        List%3CItem%3E items;%0A    %7D%0A%0A    static class Item %7B%0A        String title;%0A        String link;%0A        String description;%0A    %7D%0A
 %7D%0A

Update EchoApplication.java