# Website abfragen



## ReaX (8. August 2008)

Hi,

ich bin gerade daran, mit Java eine HTML Website abzufragen.

Wenn die Website, also der HTML Code kurz ist geht das auch ohne Probleme, aber wenn es länger wird, kann sein, dass die Exception kommt:


```
java.io.IOException: Premature EOF
	at sun.net.www.http.ChunkedInputStream.fastRead(ChunkedInputStream.java:234)
	at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:662)
	at java.io.FilterInputStream.read(FilterInputStream.java:111)
	at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2139)
	at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
	at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
	at java.io.InputStreamReader.read(InputStreamReader.java:167)
	at java.io.BufferedReader.fill(BufferedReader.java:136)
	at java.io.BufferedReader.readLine(BufferedReader.java:299)
	at java.io.BufferedReader.readLine(BufferedReader.java:362)
	at Start.getSite(Start.java:179)
```

Woran liegt das? Die Website tu ich wie folgt aufrufen:


```
..
URLConnection conn = url.openConnection();

BufferedReader inS = new BufferedReader( new InputStreamReader( conn.getInputStream() ));

while ( text != null ) {

	text = inS.readLine();
					
	System.out.println( text );
}
..
```

Schon mal Danke..


----------



## Looky (9. August 2008)

mhm, versuchs ma so...



```
URLConnection conn = url.openConnection();
BufferedReader inS = new BufferedReader( new InputStreamReader( conn.getInputStream() ));
while ( (text  = inS.readLine())!= null ) {
    System.out.println( text );
}
```


----------

