1 |
String line; // Here is a useful example
|
2 |
try { URLConnection conn = npacurl.openConnection();
|
3 |
conn.connect(); // could set options after creation of conn in above line and before connect method invoked
|
4 |
InputStream in = conn.getInputStream(); // establish an InputStream on this connection
|
5 |
DataInputStream data = new DataInputStream(new BufferedInputSream(in)); // set up two filters allowing both buffering and line access to InputStream
|
6 |
while ((line = data.readline()) != null ) {
-
System.out.println("line"); } // print out line -- obviously put your favorite line processing here
|
7 |
} catch (IOException e) { process error }
|
8 |
Note one useful exception EOFException which can be caught and remove testing in read loops
|