D
Dave Neuendorf
I'm trying to use Runtime.exec to execute the Windows XP copy command,
to back up a file to another location on the same hard drive. Here is
the code I'm using to do this (where backupDirectory is a File instance
for the directory where I want to store the copy):
String dest = backupDirectory.getAbsolutePath() + "\\" +
DATABASE_FILE_NAME;
String sourceFile = DATABASE_PATH + "\\" + DATABASE_FILE_NAME;
String[] command = { "cmd.exe", "copy", sourceFile, dest };
Runtime.getRuntime().exec( command );
This does not throw any exceptions, but the copy is not made. If I call
waitFor() on the Process returned by exec(), and put the code in a
try/finally structure, the code in the finally never gets executed, so
it looks like it never gets past the waitFor().
I would appreciate any help.
Thanks,
Dave Neuendorf
to back up a file to another location on the same hard drive. Here is
the code I'm using to do this (where backupDirectory is a File instance
for the directory where I want to store the copy):
String dest = backupDirectory.getAbsolutePath() + "\\" +
DATABASE_FILE_NAME;
String sourceFile = DATABASE_PATH + "\\" + DATABASE_FILE_NAME;
String[] command = { "cmd.exe", "copy", sourceFile, dest };
Runtime.getRuntime().exec( command );
This does not throw any exceptions, but the copy is not made. If I call
waitFor() on the Process returned by exec(), and put the code in a
try/finally structure, the code in the finally never gets executed, so
it looks like it never gets past the waitFor().
I would appreciate any help.
Thanks,
Dave Neuendorf