public abstract class CommandLine extends Object
CommandLine is a base class for command line parsing
 classes.  It provides several useful methods for the implementor
 of the subclass and for the programmer.  It also defines exceptions
 that can be generated during parsing commands.
 
 CommandLine provides you several methods to get input
 streams from the command line.  If these do not suffice for your
 particular needs, you can get the argument as a String
 and do your own processing.
 
 You can use these methods to parse your own operand arguments.  For
 example, if your operands are integers, you may want to use
 parseInt to parse them to provide consistency to the
 user.
POSIXCommandLine, 
MultiCommandLine| Modifier and Type | Class and Description | 
|---|---|
| static class  | CommandLine.BadInvocationExceptionSignal that the user specified an option in an improper way. | 
| static class  | CommandLine.HelpOnlyExceptionSignal that this was a "help only" invocation. | 
| static class  | CommandLine.ProgrammingExceptionSignal that the programmer has invoked a method out of order. | 
| Constructor and Description | 
|---|
| CommandLine() | 
| Modifier and Type | Method and Description | 
|---|---|
| static double | parseDouble(String str,
           double defaultValue)Return the result of parsing the given  doublefrom
 the command line. | 
| static InputStream | parseInputStream(String path,
                InputStream defaultValue)Return a  InputStreamthat is the result of creating
 a newFileInputStreamobject for the file named by
 the givenpath. | 
| static InputStream | parseInputStream(String path,
                String defaultPath)Return a  InputStreamthat is the result of creating
 a newFileInputStreamobject for the file named by
 the givenpath. | 
| static int | parseInt(String str,
        int defaultValue)Return the result of parsing the given  intfrom the
 command line. | 
| static long | parseLong(String str,
         long defaultValue)Return the result of parsing the given  longfrom
 the command line. | 
| static OutputStream | parseOutputStream(String path,
                 OutputStream defaultValue)Return a  OutputStreamthat is the result of
 creating a newFileOutputStreamobject for the file
 named by the givenpath. | 
| static OutputStream | parseOutputStream(String path,
                 String defaultPath)Return a  InputStreamthat is the result of creating
 a newFileInputStreamobject for the file named by
 the givenpath. | 
| static RandomAccessFile | parseRandomAccessFile(String path,
                     RandomAccessFile defaultValue,
                     String mode)Return a  RandomAccessFilethat is the result of
 creating a newRandomAccessFileobject for the file
 named by the givenpath, using the givenmode. | 
| static RandomAccessFile | parseRandomAccessFile(String path,
                     String defaultPath,
                     String mode)Return a  RandomAccessFilethat is the result of
 creating a newRandomAccessFileobject for the file
 named by the givenpath, using the givenmode. | 
| static Reader | parseReader(String path,
           Reader defaultValue)Return a  Readerthat is the result of creating a
 newFileReaderobject for the file named by the
 givenpath. | 
| static Reader | parseReader(String path,
           String defaultPath)Return a  Readerthat is the result of creating a
 newFileReaderobject for the file named by the
 givenpath. | 
| static String | parseString(String str,
           String defaultValue)Return the result of parsing the given string from the command
 line. | 
| static Writer | parseWriter(String path,
           String defaultPath)Return a  Writerthat is the result of creating a
 newFileWriterobject for the file named by the
 givenpath. | 
| static Writer | parseWriter(String path,
           Writer defaultValue)Return a  Writerthat is the result of creating a
 newFileWriterobject for the file named by the
 givenpath. | 
public static String parseString(String str, String defaultValue)
str is null, return
 defaultValue.public static int parseInt(String str, int defaultValue) throws NumberFormatException
int from the
 command line.  If str is null, return
 defaultValue.  The value is parsed using to
 understand leading 0x or # to
 introduce a hexidecimal number, leading 0 to
 introduce an octal number, and anything else to be a decimal
 number.NumberFormatExceptionpublic static long parseLong(String str, long defaultValue) throws NumberFormatException
long from
 the command line.  If str is null,
 return defaultValue.  The value is parsed using to
 understand leading 0x or # to
 introduce a hexidecimal number, leading 0 to
 introduce an octal number, and anything else to be a decimal
 number.NumberFormatExceptionpublic static double parseDouble(String str, double defaultValue) throws NumberFormatException
double from
 the command line.  If str is null,
 return defaultValue.  The value is parsed using
 Double.value.NumberFormatExceptionpublic static Writer parseWriter(String path, Writer defaultValue) throws IOException
Writer that is the result of creating a
 new FileWriter object for the file named by the
 given path.  If the argument is `-' then
 an OutputStreamWriter for System.out
 is returned.  If path is null, return
 defaultValue.IOExceptionpublic static Writer parseWriter(String path, String defaultPath) throws IOException
Writer that is the result of creating a
 new FileWriter object for the file named by the
 given path.  If the argument is `-' then
 an OutputStreamWriter for System.out
 is returned.  If path is null, the
 string path is used as the file name.IOExceptionpublic static Reader parseReader(String path, Reader defaultValue) throws IOException
Reader that is the result of creating a
 new FileReader object for the file named by the
 given path.  If the argument is `-' then
 an InputStreamReader for System.in is
 returned.  If path is null, return
 defaultValue.IOExceptionpublic static Reader parseReader(String path, String defaultPath) throws IOException
Reader that is the result of creating a
 new FileReader object for the file named by the
 given path.  If the argument is `-' then
 an InputStreamReader for System.in is
 returned.  If path is null, the string
 path is used as the file name.IOExceptionpublic static OutputStream parseOutputStream(String path, OutputStream defaultValue) throws IOException
OutputStream that is the result of
 creating a new FileOutputStream object for the file
 named by the given path.  If the argument is
 `-' then System.out is returned.  If
 path is null, return
 defaultValue.IOExceptionpublic static OutputStream parseOutputStream(String path, String defaultPath) throws IOException
InputStream that is the result of creating
 a new FileInputStream object for the file named by
 the given path.  If the argument is `-'
 then System.in is returned.  If path
 is null, the string path is used as
 the file name.IOExceptionpublic static InputStream parseInputStream(String path, InputStream defaultValue) throws IOException
InputStream that is the result of creating
 a new FileInputStream object for the file named by
 the given path.  If the argument is `-'
 then System.in is returned.  If path
 is null, return defaultValue.IOExceptionpublic static InputStream parseInputStream(String path, String defaultPath) throws IOException
InputStream that is the result of creating
 a new FileInputStream object for the file named by
 the given path.  If the argument is `-'
 then System.in is returned.  If path
 is null, the string path is used as
 the file name.IOExceptionpublic static RandomAccessFile parseRandomAccessFile(String path, RandomAccessFile defaultValue, String mode) throws IOException
RandomAccessFile that is the result of
 creating a new RandomAccessFile object for the file
 named by the given path, using the given
 mode.  If path is null,
 return defaultValue.IOExceptionpublic static RandomAccessFile parseRandomAccessFile(String path, String defaultPath, String mode) throws IOException
RandomAccessFile that is the result of
 creating a new RandomAccessFile object for the file
 named by the given path, using the given
 mode.  If path is null,
 the string path is used as the file name.IOExceptionCopyright © 2016–2018. All rights reserved.