Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Files using Runtime

Status
Not open for further replies.

penguin321

Programmer
Sep 20, 2001
7
US
I am having a problem. I am tring to copy a file from one location to another using the Runtime object, but can't seem to get it to work. I keep getting the following error:

CreateProcess: copy C:\recap.tbl C:\remote\recap.tbl error=2

Does anyone know what this means? This is the code which is causing the exception:

Runtime rt = Runtime.getRuntime();
rt.exec(ComUtility.getBlisProperty("RemoteBillSys"));
 
Sorry. In the above post. The ComUtility class returns the following string:
copy C:\\recap.tbl C:\\remote\\recap.tbl

 
Hi,

Firstly I have to say that I not so familiar with runtime exec that I could explain that error, but try to execute that command using rt.exec("cmd /c " + ComUtility.getBlisProperty("RemoteBillSys"));

-Vepo
 
May I ask why you are using the Runtime object instead of the standard Java Input/Output Streams for this task? The problem with using the Runtime object is that you are (obviously) limited yourself to only one platform and you are losing a lot of the benefits of Java because the process is no longer running in the JVM.
 
wushutwist,
Our client is not satisifed with writing the file directly to the server location. If I am writing using Input/Output Streams (which is how I am building the file in the first place) then there would be no reason to copy the file from the local machine to the server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top