hy
ich habe aus einem Javabuch den Quellcode sorgfältig abgeschrieben!
Leider kommen folgende Fehlermeldungen heraus:
"uebung_netzwerke.java": unreported exception java.net.UnknownHostException; must be caught or declared to be thrown at line 35, column 17
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 35, column 17
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 38, column 26
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 40, column 28
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 49, column 42
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 54, column 16
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 55, column 7
Zeilenangaben stimmen nicht überein!!
Weiss jemand an was das liegt?
Herzlichen Dank
m.
ich habe aus einem Javabuch den Quellcode sorgfältig abgeschrieben!
Code:
import java.net.*;
import java.io.*;
public class uebung_netzwerke{
public static void main(String[] args){
String hostname = "java.oreilly.com";
int port = 80;
String filename = "/index.html";
Socket s = new Socket(hostname,port);
InputStream sin = s.getInputStream();
BufferedReader fromServer = new BufferedReader(new InputStreamReader(sin));
OutputStream sout = s.getOutputStream();
PrintWriter toServer = new PrintWriter(new OutputStreamWriter(sout));
toServer.print("GET " + filename + "HTTP/1.0\r\n\r\n");
toServer.flush();
for(String l = null; (l= fromServer.readLine()) != null;)
System.out.println(l);
toServer.close();
fromServer.close();
s.close();
}
}
Leider kommen folgende Fehlermeldungen heraus:
"uebung_netzwerke.java": unreported exception java.net.UnknownHostException; must be caught or declared to be thrown at line 35, column 17
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 35, column 17
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 38, column 26
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 40, column 28
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 49, column 42
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 54, column 16
"uebung_netzwerke.java": unreported exception java.io.IOException; must be caught or declared to be thrown at line 55, column 7
Zeilenangaben stimmen nicht überein!!
Weiss jemand an was das liegt?
Herzlichen Dank
m.