FileDocCategorySizeDatePackage
TextFile.javaAPI DocExample2448Wed May 26 10:43:12 BST 2004com.oreilly.tiger.ch07

TextFile

public class TextFile extends Object implements Iterable
This class allows line-by-line iteration through a text file. The iterator's remove() method throws UnsupportedOperatorException. The iterator wraps and rethrows IOExceptions as IllegalArgumentExceptions.

Fields Summary
final String
filename
Constructors Summary
public TextFile(String filename)

 
    this.filename = filename; 
  
Methods Summary
public java.util.Iteratoriterator()

 
    return new TextFileIterator(); 
  
public static voidmain(java.lang.String[] args)

    String filename = "TextFile.java";
    if (args.length > 0) 
      filename = args[0];

    for(String line : new TextFile(filename))
      System.out.println(line);