import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLConnection;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class WebPageReader {
private URLConnection connection;
public void connect( String urlString ) {
try {
URL url = new URL(urlString);
connection = url.openConnection();
System.out.println(connection.getClass());
} catch (MalformedURLException e){
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void readContents() {
BufferedReader in = null;
try {
in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String inputLine;
while (
(inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String []args){
WebPageReader w=new WebPageReader();
w.connect("http://xxxxx/1.txt ");
w.readContents();
}
}