org.tranche.util
Class OperatingSystemUtil

java.lang.Object
  extended by org.tranche.util.OperatingSystemUtil

public class OperatingSystemUtil
extends java.lang.Object

Utility methods for interacting with the operating system.

Author:
Bryan E. Smith - bryanesmith@gmail.com

Constructor Summary
OperatingSystemUtil()
           
 
Method Summary
static java.io.File escapeFileName(java.io.File file)
          Safely escape file so that name doesn't have illegal characters for any operating system, but using Windows illegal character list to escape characters.
static java.io.File escapeFileNameForWindows(java.io.File file)
          Safely escape file so that name doesn't have illegal characters for Windows.
static int executeExternalCommand(java.lang.String command)
          Run an external app using Runtime.
static int executeUnixCommandWithOutputRedirect(java.lang.String command, java.io.File outputFile)
          Run an external app using Runtime in Unix, and redirect all output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperatingSystemUtil

public OperatingSystemUtil()
Method Detail

executeExternalCommand

public static int executeExternalCommand(java.lang.String command)
                                  throws java.lang.Exception

Run an external app using Runtime. Should work for Windows XP and other OS.

Note that you should just type the command as if at a prompt. Do not include "cmd \c " prefix for Windows.

Parameters:
command - Just the application name and paramters.
Returns:
The exit status code.
Throws:
java.lang.Exception

executeUnixCommandWithOutputRedirect

public static int executeUnixCommandWithOutputRedirect(java.lang.String command,
                                                       java.io.File outputFile)
                                                throws java.lang.Exception

Run an external app using Runtime in Unix, and redirect all output.

Parameters:
command - Just the application name and paramters.
outputFile - The files for all output: standard error and output. All output is appended.
Returns:
The exit status code.
Throws:
java.lang.Exception

escapeFileName

public static java.io.File escapeFileName(java.io.File file)

Safely escape file so that name doesn't have illegal characters for any operating system, but using Windows illegal character list to escape characters.

Parameters:
file -
Returns:

escapeFileNameForWindows

public static java.io.File escapeFileNameForWindows(java.io.File file)

Safely escape file so that name doesn't have illegal characters for Windows.

Parameters:
file -
Returns:


This code is free for use both commercially and non-commercially as stated in the project's license