Image:LineIterator.java
From Carboogle
LineIterator.java
(4KB, MIME type: unknown/unknown)
Warning: This file may contain malicious code, by executing it your system may be compromised.
import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Iterator; import java.util.NoSuchElementException; /** * Iterator over each line of a resource : file, url, ... */ { private String next; /** * Create a new line iterator on a resource * @param resource The resource * @throws IOException The iterator could not be created */ { super(); next = in.readLine(); } /** * @see java.util.Iterator#hasNext() */ public boolean hasNext() { return next != null; } /** * @see java.util.Iterator#next() */ { // If there is no next element we throw an exception as stated in the interface if (next == null) { } // prefetch next line for optimization final String current = next; try { next = in.readLine(); } { next = null; } // If an error occured or if the stream has no new line if (next == null) { try { in.close(); } { // nothing to do } } return current; } /** * @see java.util.Iterator#remove() */ public void remove() { } /** * TEST METHOD * @param args args */ { int count; nf.setMinimumIntegerDigits(4); nf.setGroupingUsed(false); nf.setParseIntegerOnly(true); // Example to retreive each lines of a caracter file : count = 0; { } // Example to retreive each lines of a web resource : count = 0; { } } }
File history
Legend: (cur) = this is the current file, (del) = delete
this old version, (rev) = revert to this old version.
Click on date to see the file uploaded on that date.
- (del) (cur) 03:34, 17 January 2006 . . Kha (3135 bytes)
- Edit this file using an external applicationSee the setup instructions for more information.
Links
The following pages link to this file:

