public class FileOps
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static int |
MAXSIZE |
| Constructor and Description |
|---|
FileOps() |
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanupProcess(java.lang.Process p)
This method shuts down / cleans up all resources related to
Process p.
|
static boolean |
copyFile(java.lang.String inputFileName,
java.lang.String outputFileName)
Copies a file named inputFileName to the location outputFileName
in an operating system independent fashion.
|
static boolean |
deleteDirectory(java.lang.String directoryName) |
static boolean |
deleteFile(java.lang.String filename) |
static void |
main(java.lang.String[] args)
Test rig
|
private static java.util.List |
runCaptureOutputProcess(java.lang.Process p)
This method is used to run an external process line for the
Ganymede server.
|
static java.util.List |
runCaptureOutputProcess(java.lang.String commandLine)
This method is used to run an external process line for the
Ganymede server.
|
static java.util.List |
runCaptureOutputProcess(java.lang.String[] cmdArgs)
This method is used to run an external process line for the
Ganymede server.
|
private static int |
runProcess(java.lang.Process p)
This method is used to run an external process line for the
Ganymede server.
|
static int |
runProcess(java.lang.String commandLine)
This method is used to run an external process line for the
Ganymede server.
|
static int |
runProcess(java.lang.String[] cmdArgs)
This method is used to run an external process line for the
Ganymede server.
|
private static void |
slurpStreams(java.io.InputStream outStream,
java.io.InputStream errStream,
java.lang.StringBuffer outBuffer,
java.lang.StringBuffer errBuffer)
Read everything we can from the passed stdout and stderr streams,
copy the data into outBuffer and errBuffer.
|
public static boolean copyFile(java.lang.String inputFileName,
java.lang.String outputFileName)
throws java.io.IOException
java.io.IOExceptionpublic static boolean deleteFile(java.lang.String filename)
throws java.io.IOException
java.io.IOExceptionpublic static boolean deleteDirectory(java.lang.String directoryName)
throws java.io.IOException
java.io.IOExceptionpublic static int runProcess(java.lang.String[] cmdArgs)
throws java.io.IOException,
java.lang.InterruptedException
This method is used to run an external process line for the Ganymede server. This method waits until the external command completes before returning, and all file handles opened to communicate with the process will be closed before returning.
While this method is waiting for the process to exit, it will spin on the stdout and stderr from the process, consuming and discarding anything written by the subprocess so as to prevent the subprocess from blocking due to its output piling up.
java.io.IOExceptionjava.lang.InterruptedExceptionpublic static int runProcess(java.lang.String commandLine)
throws java.io.IOException,
java.lang.InterruptedException
This method is used to run an external process line for the Ganymede server. This method waits until the external command completes before returning, and all file handles opened to communicate with the process will be closed before returning.
While this method is waiting for the process to exit, it will spin on the stdout and stderr from the process, consuming and discarding anything written by the subprocess so as to prevent the subprocess from blocking due to its output piling up.
java.io.IOExceptionjava.lang.InterruptedExceptionprivate static int runProcess(java.lang.Process p)
throws java.io.IOException,
java.lang.InterruptedException
This method is used to run an external process line for the Ganymede server. This method waits until the external command completes before returning, and all file handles opened to communicate with the process will be closed before returning.
While this method is waiting for the process to exit, it will spin on the stdout and stderr from the process, consuming and discarding anything written by the subprocess so as to prevent the subprocess from blocking due to its output piling up.
java.io.IOExceptionjava.lang.InterruptedExceptionpublic static java.util.List runCaptureOutputProcess(java.lang.String[] cmdArgs)
throws java.io.IOException,
java.lang.InterruptedException
This method is used to run an external process line for the Ganymede server. This method waits until the external command completes before returning, and all file handles opened to communicate with the process will be closed before returning.
java.io.IOExceptionjava.lang.InterruptedExceptionpublic static java.util.List runCaptureOutputProcess(java.lang.String commandLine)
throws java.io.IOException,
java.lang.InterruptedException
This method is used to run an external process line for the Ganymede server. This method waits until the external command completes before returning, and all file handles opened to communicate with the process will be closed before returning.
java.io.IOExceptionjava.lang.InterruptedExceptionprivate static java.util.List runCaptureOutputProcess(java.lang.Process p)
throws java.io.IOException,
java.lang.InterruptedException
This method is used to run an external process line for the Ganymede server. This method waits until the external command completes before returning, and all file handles opened to communicate with the process will be closed before returning.
java.io.IOExceptionjava.lang.InterruptedExceptionprivate static void slurpStreams(java.io.InputStream outStream,
java.io.InputStream errStream,
java.lang.StringBuffer outBuffer,
java.lang.StringBuffer errBuffer)
public static void cleanupProcess(java.lang.Process p)
This method shuts down / cleans up all resources related to Process p. The following is mentioned as a work-around for the fact that Process keeps its file descriptors open by default until Garbage Collection.
public static void main(java.lang.String[] args)