|
JAPI 0.9.0 Yet another Java API API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Reader
java.io.BufferedReader
net.sf.japi.io.ARGVReader
public class ARGVReader
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; ) { lineList.append(line); } Collections.sort(lineList); for (final String line : lineList) { System.out.println(lines[i]); } } }Internally this class uses
ARGVInputStream
, which uses ARGVEnumeration
to sequentially access the Stream elements of ARGV.
ARGVInputStream
,
ARGVEnumeration
BufferedReader.close()
.Field Summary |
---|
Fields inherited from class java.io.Reader |
---|
lock |
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)
args
- Command line arguments or some other String array containing 0 or more file names.
|
JAPI Yet another Java API API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |