public final class DefaultCmdlineContext extends Object implements CmdlineContext
CmdlineContext.ExitWithNonZeroStatus, CmdlineContext.ExitWithZeroStatus| Constructor and Description |
|---|
DefaultCmdlineContext()
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
PrintStream |
err()
Error stream, usually mapped to
System.err. |
void |
exit(int status)
Terminate execution with given status code.
|
InputStream |
in()
Input stream, usually mapped to
System.in. |
boolean |
isFileExists(String name)
Check if a file exists.
|
InputStream |
openFileInput(String name)
Open a file for reading.
|
OutputStream |
openFileOutput(String name)
Open a file for writing.
|
InputStream |
openUrlStream(String spec)
Open a connection to an URL.
|
PrintStream |
out()
Output stream, usually mapped to
System.out. |
SeekableFileOutput |
seekableFileOutput(String name)
Open a seekable file for writing.
|
public PrintStream out()
CmdlineContextSystem.out.out in interface CmdlineContextpublic PrintStream err()
CmdlineContextSystem.err.err in interface CmdlineContextpublic InputStream in()
CmdlineContextSystem.in.in in interface CmdlineContextpublic InputStream openFileInput(String name) throws FileNotFoundException
CmdlineContextFileInputStream.FileInputStream(java.lang.String).openFileInput in interface CmdlineContextname - File name to openFileNotFoundExceptionpublic OutputStream openFileOutput(String name) throws FileNotFoundException
CmdlineContextFileOutputStream.FileOutputStream(java.lang.String).openFileOutput in interface CmdlineContextname - File name to openFileNotFoundExceptionpublic SeekableFileOutput seekableFileOutput(String name) throws FileNotFoundException
CmdlineContextseekableFileOutput in interface CmdlineContextname - File name to openFileNotFoundExceptionpublic void exit(int status)
throws CmdlineContext.ExitWithZeroStatus,
CmdlineContext.ExitWithNonZeroStatus
CmdlineContextSystem.exit(int). Test time implementations might decide to throw
CmdlineContext.ExitWithZeroStatus or CmdlineContext.ExitWithNonZeroStatus instead of delegating to System.exit(int).
These RuntimeExceptions are helps for test implementations, regular application code must not catch them.exit in interface CmdlineContextstatus - Status code; by convention nonzero status code indicates abnormal terminationCmdlineContext.ExitWithZeroStatus - Test time implementation might throw this instead of delegating to
System.exit(int) Note that normal application code must not catch this.CmdlineContext.ExitWithNonZeroStatus - Test time implementation might throw this instead of delegating to
System.exit(int) Note that normal application code must not catch this.public boolean isFileExists(String name)
CmdlineContextFile.exists() of an instance created by File.File(java.lang.String).isFileExists in interface CmdlineContextname - File name to checktrue when given file existspublic InputStream openUrlStream(String spec) throws IOException
CmdlineContextURL.openStream() of an instance created by URL.URL(java.lang.String).openUrlStream in interface CmdlineContextspec - The String to parse as an URL.IOException - propagated