Monday, March 23, 2015

Simplest Codes in JAVA- Reading from a URL

package readingfromaurl;
import java.io.*;
import java.net.*;

        public class ReadingFromAURL {
        public static void main(String[] args) throws Exception {
        URL oracle = new URL("http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html");
        URLConnection yc = oracle.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);}}

No comments:

Post a Comment