Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.ifs.utils.common
Class OsUtils

    java.lang.Object
      oracle.ifs.utils.common.OsUtils

    public class OsUtils

extends java.lang.Object

A collection of utility methods for performing OS-level tasks.

Modified:
  mhong 12/27/2005 Added isOsAix for AIX platform., aknatara29/07/2005 Added chkTmpPermission method., sgarg 01/23/2004 Modified isOsWindowsFamily() to check against "windows" string instead of specific version., aknatara11/18/2003 isOsSolaris28 checks for Solaris 2.8 (SunOS 5.8), sgarg 10/02/2003 isOsWindowsFamily checks Windows XP also now., lsaenz 05/24/2001 isOsWindowsFamily checks Win95,98,2K, or NT., lsaenz 10/09/2000 Fixed bug in getUniqueFileName method., lsaenz 08/02/2000 Added squeezeOut method., lsaenz 07/31/2000 Changed OS query method., lsaenz 03/26/2000 Made runPgm methods static; updated comments., lsaenz 02/14/2000 Removed native methods, removed abstract methods, removed subclasses; they were never used and are unecessary., lsaenz 12/08/1999 Added variant to getFilenameWithCorrect... new method takes a separator char as input, so that clients can replace a filename string with any file-separator character they want., lsaenz 12/03/1999 Made a few methods static., lsaenz 12/02/1999 Added getFilenameWithCorrectPathSeparators()., lsaenz 11/07/1999 Added getUniqueFileName(), fixed copyFile() to work with same source and destination., lsaenz 08/26/1999 Removed some methods, replaced some native methods with Java code, updated comments., echui 01/18/1999 Modified setCurrentDirectory() to throw an exception., echui 01/12/1999 Fixed deadlock problem in runPgm()., echui 01/12/1999 Added networking methods., echui 12/16/1998 Removed loading native library., echui 10/15/1998 Added a class for string subsitution., echui 10/14/1998 Put OS name in static block instead of in constructor., echui 10/08/1998 Created.

Field Summary
`static char[]` | `fileSeparators` All known file-separator characters.
`static java.lang.String` | `ORA_EXTENSION` Oracle initialization files extension.
`static java.lang.String` | `OS_AIX` The name of the AIX operating system: "AIX".
`static java.lang.String` | `OS_SOLARIS` The name of the Solaris operating system: "Solaris".
`static java.lang.String` | `OS_SUNOS` The name of the SunOS operating system: "SunOS".
`static java.lang.String` | `OS_WINDOWS_2000` The name of the Windows 2000 operating system: "Windows 2000".
`static java.lang.String` | `OS_WINDOWS_95` The name of the Windows 95 operating system: "Windows 95".
`static java.lang.String` | `OS_WINDOWS_98` The name of the Windows 98 operating system: "Windows 98".
`static java.lang.String` | `OS_WINDOWS_NT` The name of the Windows NT operating system: "Windows NT".
`static java.lang.String` | `OS_WINDOWS_XP` The name of the Windows XP operating system: "Windows XP".

Constructor Summary
`OsUtils()` Creates a new OsUtils.

Method Summary
`void` | `appendFile(java.lang.String outfile, java.lang.String infile)` Appends `infile` to `outfile`.
`boolean` | `backupFile(java.lang.String filename)` Backup a file: copy it to a new file with a numbered 3-character extension (between 0 and 999).
`static boolean` | `chkTmpPermission()` Checks the permission of the system-defaulted temp folder, specified by the system property java.io.tmpdir by creating a temp file using the java API File.createTempFile.
`static void` | `copyFile(java.lang.String source, java.lang.String dest)` Copies a file.
`static void` | `copyStream(java.io.InputStream source, java.io.OutputStream dest)` Copies a stream.
`static void` | `copyStream(java.io.Reader source, java.io.Writer dest)` Copies a character-based stream.
`static boolean` | `deleteFile(java.lang.String filename)` Deletes a file or an empty directory.
`static java.lang.String` | `getFilenameWithCorrectFileSeparators(java.lang.String filename)` Converts any known file-separator characters in the given String to this operating system's file-separator character.
`static java.lang.String` | `getFilenameWithCorrectFileSeparators(java.lang.String filename, char separator)` Converts any known file-separator characters in the given String to the given file-separator character.
`java.lang.String` | `getLocalHostName()` Returns this machine's DNS hostname.
`int` | `getTimeZoneOffset()` Returns the number of milliseconds to add to GMT to convert to this machine's timezone, correcting for daylight savings time.
`static boolean` | `isOsAix()` Returns true if the operating system is AIX.
`static boolean` | `isOsSolaris28()` Returns true if the operating system is Solaris 2.8 which also includes SunOS 5.8 on which Solaris 2.8 is built Checks the System property "os.name" and "os.version", returns true if it is equal to: Solaris or SunOS 2.8 or 5.8 respectively.
`static boolean` | `isOsWindowsFamily()` Returns true if the operating system is within the "Windows family".
`static void` | `moveFile(java.lang.String source, java.lang.String dest)` Moves a file.
`static void` | `runPgm(java.lang.String[] cmdarray)` Executes a program external to the Java VM.
`static void` | `runPgm(java.lang.String[] cmdarray, java.lang.String inputFile)` Executes a program external to the Java VM, passing an InputStream to the program from the file named `inputFile`.
`static java.lang.Process` | `runPgmAsync(java.lang.String[] cmdarray)` Asynchronously executes a Process external to the Java VM.
`static java.lang.Process` | `runPgmAsync(java.lang.String[] cmdarray, java.lang.String inputFile)` Asynchronously executes a Process external to the Java VM, passing an InputStream to the program from the file named `inputFile`.
`static java.lang.String` | `squeezeOut(java.lang.String from, char toss)` Removes all occurances of a character from a String.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### OS_WINDOWS_NT

    public static final java.lang.String OS_WINDOWS_NT

  Description copied from class: `OsUtils`
  The name of the Windows NT operating system: "Windows NT".

  See Also:
    Constant Field Values

### OS_WINDOWS_95

    public static final java.lang.String OS_WINDOWS_95

  Description copied from class: `OsUtils`
  The name of the Windows 95 operating system: "Windows 95".

  See Also:
    Constant Field Values

### OS_WINDOWS_98

    public static final java.lang.String OS_WINDOWS_98

  Description copied from class: `OsUtils`
  The name of the Windows 98 operating system: "Windows 98".

  See Also:
    Constant Field Values

### OS_WINDOWS_2000

    public static final java.lang.String OS_WINDOWS_2000

  Description copied from class: `OsUtils`
  The name of the Windows 2000 operating system: "Windows 2000".

  See Also:
    Constant Field Values

### OS_WINDOWS_XP

    public static final java.lang.String OS_WINDOWS_XP

  Description copied from class: `OsUtils`
  The name of the Windows XP operating system: "Windows XP".

  See Also:
    Constant Field Values

### OS_SOLARIS

    public static final java.lang.String OS_SOLARIS

  Description copied from class: `OsUtils`
  The name of the Solaris operating system: "Solaris".

  See Also:
    Constant Field Values

### OS_SUNOS

    public static final java.lang.String OS_SUNOS

  Description copied from class: `OsUtils`
  The name of the SunOS operating system: "SunOS".

  See Also:
    Constant Field Values

### OS_AIX

    public static final java.lang.String OS_AIX

  Description copied from class: `OsUtils`
  The name of the AIX operating system: "AIX".

  See Also:
    Constant Field Values

### fileSeparators

    public static final char[] fileSeparators

  Description copied from class: `OsUtils`
  All known file-separator characters.
  This is a char array consisting of the following: {'/', '\'}

### ORA_EXTENSION

    public static final java.lang.String ORA_EXTENSION

  Description copied from class: `OsUtils`
  Oracle initialization files extension.

  See Also:
    Constant Field Values

Constructor Detail

### OsUtils

    public OsUtils()

  Creates a new OsUtils.

Method Detail

### isOsWindowsFamily

    public static boolean isOsWindowsFamily()

  Description copied from class: `OsUtils`
  Returns true if the operating system is within the "Windows family". Checks the System property "os.name" and returns true if it starts with Windows. The check is made case-insensitively.

### isOsSolaris28

    public static boolean isOsSolaris28()

  Description copied from class: `OsUtils`
  Returns true if the operating system is Solaris 2.8 which also includes SunOS 5.8 on which Solaris 2.8 is built Checks the System property "os.name" and "os.version", returns true if it is equal to: Solaris or SunOS 2.8 or 5.8 respectively. The check is made case-insensitively.

### isOsAix

    public static boolean isOsAix()

  Description copied from class: `OsUtils`
  Returns true if the operating system is AIX. Checks the System property "os.name" and returns true if it is equal to "AIX". The check is made case-insensitively.

### appendFile

    public void appendFile(java.lang.String outfile,
                           java.lang.String infile)
                    throws java.io.IOException

  Description copied from class: `OsUtils`
  Appends `infile` to `outfile`.

  Parameters:
    `outfile` - the name of the file to append to.
    `infile` - the name of the file which will be appended.
  Throws:
    `java.io.IOException`

### backupFile

    public boolean backupFile(java.lang.String filename)

  Description copied from class: `OsUtils`
  Backup a file: copy it to a new file with a numbered 3-character extension (between 0 and 999).

  Parameters:
    `filename` - the name of the file to backup.
  Returns:
    true if the operation was successful.

### deleteFile

    public static boolean deleteFile(java.lang.String filename)

  Description copied from class: `OsUtils`
  Deletes a file or an empty directory.

  Parameters:
    `filename` - the name of the file to delete.
  Returns:
    true if the file or directory was deleted.

### runPgm

    public static void runPgm(java.lang.String[] cmdarray)
                       throws java.io.IOException

  Description copied from class: `OsUtils`
  Executes a program external to the Java VM.
  Note: this is a blocking call.

  Parameters:
    `cmdarray` - the name of the program to execute, with arguments.
  Throws:
    `java.io.IOException` - if an error occurs when executing the Process.
    `java.lang.IllegalArgumentException` - if `cmdarray` has no elements.
    `java.lang.NullPointerException` - if `cmdarray` is null.

### runPgm

    public static void runPgm(java.lang.String[] cmdarray,
                              java.lang.String inputFile)
                       throws java.io.IOException

  Description copied from class: `OsUtils`
  Executes a program external to the Java VM, passing an InputStream to the program from the file named `inputFile`.
  Note: this is a blocking call.

  Parameters:
    `cmdarray` - the name of the program to execute, with arguments.
    `inputFile` - the name of the file to use as an InputStream.
  Throws:
    `java.io.IOException` - if an error occurs when executing the Process.
    `java.lang.IllegalArgumentException` - if `cmdarray` has no elements.
    `java.lang.NullPointerException` - if `cmdarray` is null.

### runPgmAsync

    public static java.lang.Process runPgmAsync(java.lang.String[] cmdarray)
                                         throws java.io.IOException

  Description copied from class: `OsUtils`
  Asynchronously executes a Process external to the Java VM.

  Parameters:
    `cmdarray` - the name of the program to execute, with arguments.
  Throws:
    `java.io.IOException` - if an error occurs when executing the Process.
    `java.lang.IllegalArgumentException` - if `cmdarray` has no elements.
    `java.lang.NullPointerException` - if `cmdarray` is null.

### runPgmAsync

    public static java.lang.Process runPgmAsync(java.lang.String[] cmdarray,
                                                java.lang.String inputFile)
                                         throws java.io.IOException

  Description copied from class: `OsUtils`
  Asynchronously executes a Process external to the Java VM, passing an InputStream to the program from the file named `inputFile`.

  Parameters:
    `cmdarray` - the name of the program to execute, with arguments.
    `inputFile` - the name of the file to use as an InputStream.
  Throws:
    `java.io.IOException` - if an error occurs when executing the Process.
    `java.lang.IllegalArgumentException` - if `cmdarray` has no elements.
    `java.lang.NullPointerException` - if `cmdarray` is null.

### moveFile

    public static void moveFile(java.lang.String source,
                                java.lang.String dest)
                         throws java.io.FileNotFoundException,
                                java.io.IOException

  Description copied from class: `OsUtils`
  Moves a file. Does nothing if the source and destination are equal.

  Parameters:
    `source` - the name of the file to move.
    `dest` - where to move the file to.
  Throws:
    `java.io.FileNotFoundException` - if the source file cannot be found.
    `java.io.IOException` - if an error occurs during copying.
    `CommonException` - if some other error occurs.

### copyFile

    public static void copyFile(java.lang.String source,
                                java.lang.String dest)
                         throws java.io.FileNotFoundException,
                                java.io.IOException

  Description copied from class: `OsUtils`
  Copies a file. Does nothing if the source and destination are equal.

  Parameters:
    `source` - the name of the file to copy.
    `dest` - the name of the copied file.
  Throws:
    `java.io.FileNotFoundException` - if the source file cannot be found.
    `java.io.IOException` - if an error occurs during copying.

### copyStream

    public static void copyStream(java.io.InputStream source,
                                  java.io.OutputStream dest)
                           throws java.io.IOException

  Description copied from class: `OsUtils`
  Copies a stream. Uses buffered streams for efficiency.

  Parameters:
    `source` - the source stream.
    `dest` - the destination stream.
  Throws:
    `java.io.IOException` - if an error occurs during copying.

### copyStream

    public static void copyStream(java.io.Reader source,
                                  java.io.Writer dest)
                           throws java.io.IOException

  Description copied from class: `OsUtils`
  Copies a character-based stream. Uses BufferedReader/Writer for efficiency.

  Parameters:
    `source` - the source Reader.
    `dest` - the destination Writer.
  Throws:
    `java.io.IOException` - if an error occurs during copying.

### getLocalHostName

    public java.lang.String getLocalHostName()
                                      throws java.net.UnknownHostException

  Description copied from class: `OsUtils`
  Returns this machine's DNS hostname.

  Returns:
    this machine's DNS hostname.
  Throws:
    `java.net.UnknownHostException` - if this machine does not have a hostname.

### getTimeZoneOffset

    public int getTimeZoneOffset()

  Description copied from class: `OsUtils`
  Returns the number of milliseconds to add to GMT to convert to this machine's timezone, correcting for daylight savings time.

  Returns:
    milliseconds to add to GMT.

### getFilenameWithCorrectFileSeparators

    public static java.lang.String getFilenameWithCorrectFileSeparators(java.lang.String filename)

  Description copied from class: `OsUtils`
  Converts any known file-separator characters in the given String to this operating system's file-separator character.
  For example, given that the known file-separator characters are "/" and "\", an input String of:
  `"e:/myDir\dirA/dirB"`
  is converted to the String:
  `"e:" + fs + "myDir" + fs + "dirA" + fs + "dirB"`
  where fs == System.getProperty("file.separator").

  Parameters:
    `filename` - the filename String to convert
  Returns:
    a filename String with this operating system's file-separator replacing any known file-separator characters in the input String.

### getFilenameWithCorrectFileSeparators

    public static java.lang.String getFilenameWithCorrectFileSeparators(java.lang.String filename,
                                                                        char separator)

  Description copied from class: `OsUtils`
  Converts any known file-separator characters in the given String to the given file-separator character.
  For example, given that the known file-separator characters are "/" and "\", an input String of:
  `"e:/myDir\dirA/dirB"`
  is converted to the String:
  `"e:" + fs + "myDir" + fs + "dirA" + fs + "dirB"`
  where fs == `separator`.

  Parameters:
    `filename` - the filename String to convert
    `separator` - the file-separator character to insert in place of every known file-separator character in the orginal filename (i.e., specify ':' for Macintosh file strings).
  Returns:
    a filename String with this operating system's file-separator replacing any known file-separator characters in the input String.

### squeezeOut

    public static java.lang.String squeezeOut(java.lang.String from,
                                              char toss)

  Description copied from class: `OsUtils`
  Removes all occurances of a character from a String. (from Arnold and Gosling, "The Java Programming Language Second Edition")

  Parameters:
    `from` - the String from which to remove the character.
    `toss` - the character to remove from the String.
  Returns:
    the String `from` without the character `toss`.

### chkTmpPermission

    public static boolean chkTmpPermission()

  Description copied from class: `OsUtils`
  Checks the permission of the system-defaulted temp folder, specified by the system property java.io.tmpdir by creating a temp file using the java API File.createTempFile. On Unix systems, it is typically defaulted to /tmp /var/tmp and in windows, it is c:\\temp.

  Returns:
    true if the temp folder has necessary permissions.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD