I would like to know how to use linux MV command from java. I have tried various code but it didnt worked for me. can u let me know how can i move a file from one directory to another directory in linux operating system from java. My question was How to use linux MV command from java not how to move a file in java.
Share
If you are running a Java app on a *nix system, and assuming your app has permission to execute the mv command try the following code
You need to create a Runtime to interface with environment your Java app is running (*nix in this case) and Process to run a process in the environment
EDIT: you may not need the Process part, as I usually use it to have my app wait for command to finish executing or to get the exitcode, so if you don’t need those you may omit the Process part