|
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.InputStream
java.io.SequenceInputStream
net.sf.japi.io.ARGVInputStream
public class ARGVInputStream
An ARGV InputStream, behaving similar as <ARGV>
in Perl.
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 SequenceInputStream
.
That is subject to change.
An ARGVInputStream
provides sequential access to one or more files.
To create an ARGVInputStream
that is just a synonym on System.in
, just pass an empty String array to its
constructor.
To create an ARGVInputStream
that sequentially accesss one file after another (similar as <ARGV>
does
in Perl), pass an array with the desired filenames to its constructor.
Errors that happen due to files that cannot be opened are always reported to System.err
and otherwise silently ignored, i.e. not reported to the main program.
Usually, you'd use ARGVInputStream
like this:
// Cat in a similar way the UNIX command cat works like import java.io.IOException; import net.sf.japi.io.ARGVInputStream; import static net.sf.japi.io.IOHelper.copy; public class Cat { public static void main(final String... args) { try { copy(new ARGVInputStream(args), System.out); } catch (final IOException e) { System.err.println(e); } } }Internally this class uses
ARGVEnumeration
to sequentially access the Stream elements of ARGV.
ARGVEnumeration
SequenceInputStream.close()
.Constructor Summary | |
---|---|
ARGVInputStream(String... args)
Create an ARGVInputStream. |
Method Summary |
---|
Methods inherited from class java.io.SequenceInputStream |
---|
available, close, read, read |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ARGVInputStream(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 |