JAPI 0.9.0
Yet another Java API
API Documentation

Class ARGVReader

  extended by java.io.Reader
      extended by java.io.BufferedReader
          extended by net.sf.japi.io.ARGVReader
All Implemented Interfaces:
Closeable, Readable

public class ARGVReader
extends BufferedReader

An ARGV Reader. Just to make life a bit less painful to Perl programmers that were reborn as Java programmers.

Don't rely on this class being a subclass of BufferedReader. That is subject to change. But you can rely on this class retaining all important methods (like readLine(), for instance).

An ARGVReader provides sequential access to one or more files. To create an ARGVReader that is just a BufferedReader on System.in, just pass an empty String array to its constructor. To create an ARGVReader that sequentially accesss one file after another (like <ARGV> does in Perl), pass an array with the desired filenames to its constructor.

Usually, you'd use ARGVReader like this:

 // Sort in a similar way the UNIX command sort works like
 public class Sort {
     public static void main(final String... args) throws IOException {
         final ARGVReader in = new ARGVReader(args);
         final List<String> lineList = new ArrayList<String>();
         for (String line; (line = in.readLine()) != null; ) {
         for (final String line : lineList) {
Internally this class uses ARGVInputStream, which uses ARGVEnumeration to sequentially access the Stream elements of ARGV.

Christian Hujer
See Also:
ARGVInputStream, ARGVEnumeration
it is not required to invoke BufferedReader.close().

Field Summary
Fields inherited from class java.io.Reader
Constructor Summary
ARGVReader(String... args)
          Create an ARGVReader.
Method Summary
Methods inherited from class java.io.BufferedReader
close, mark, markSupported, read, read, readLine, ready, reset, skip
Methods inherited from class java.io.Reader
read, read
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ARGVReader(String... args)
Create an ARGVReader.

args - Command line arguments or some other String array containing 0 or more file names.

Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright