 <p>Here's one possible way of reading a file and getting just the "chunks":</p> <pre><code>import java.io.*; import java.util.Scanner; public class ScanXan { public static void main(String[] args) throws IOException { Scanner s = null; try { s = new Scanner(new BufferedReader(new FileReader("xanadu.txt"))); while (s.hasNext()) { System.out.println(s.next()); } } finally { if (s != null) { s.close(); } } } } </code></pre> <p>You can take a look at the <a href="http://docs.oracle.com/javase/tutorial/essential/io/scanning.html" rel="nofollow">Java Scanner Tutorial</a> for other ideas.</p>