Runtime.getRuntime().exec()
May 5, 2006 · Posted in java
To copy a file, you can use the following command:
copy source.txt destination.txt
To run this in Java,
String[] cmd = {“copy”,”source.txt”,”destination.txt”}
Runtime.getRuntime().exec(cmd);
This may generate error=2. To fix this, use the complete path of copy.exe
eg. C:\Windows\System32\copy.exe
Comments
Leave a Reply
