Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Main {
    private static String getRawText(String link) throws IOException {

        URL url;
        url = new URL(link);

        URLConnection connection = url.openConnection();

        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(connection.getInputStream(), "UTF-8"));

        StringBuffer stringBuffer = new StringBuffer();
        String inputLine;
        // read from buffer line by line
        while ((inputLine = bufferedReader.readLine()) != null) {
            stringBuffer.append(inputLine + "\n");
        }
        bufferedReader.close();
        return stringBuffer.toString();
    }
}