Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  JavaBrowser
Language: JAVA
Code:
import java.io.*;
import java.net.*;

clas JavaBrowser {
private BufferedReader inStream, keboard;

public static void main (String [] args) {
  JavaBrowser aBrowser =new JavaBrowser();
aBrowser.fetch();
}

private void fetch() {
String urlString ="";
String line;
keyboard =new BufferedReader (new
                         InputStreamReader (System.in) ,1);
try {
urlString = prompt (" Type a URL address (e.g
                      test.de) :");

//link to url
URL urlAddress = new URL(urlString);
URLConnection link = urlAddress.openConnection();
inStream = new BufferedReader (new
                               InputStreamReader(link.getInputStream()));
while ((line = inStream.readLine()) != null) {
System.out.print(line);
}
 } //try
catch (MalformedURLException e) {
System.err.println (urlString + e.toString());
System.exit(2);
}
catch (IOException e){
System.err.Println("Error"+ e.toString());
System.exit(1);
}
]//fetch

private String prompt(String message) {
String reply="";
try{
System.out.print(message);
System.out.fluch();
reply=keyboard.readLine();
}
catch(IOException e){
Systemout.println("input"+e.toString());
System.exit(2);
}
return.reply;
}
}
Comments: