Hi All, I am trying to run UNIX move command using Java exec method but its throwing error, unable to rename. Here below is the code i am trying to run to move all files from one directory to another directory. source and destination directory exists.
if i give "mv /home/demo1 /home/demo2" in exec method, its working, with * character its giving problem.
Please help me in resolving the problem. Thank you [ December 12, 2008: Message edited by: Martijn Verburg ]
Normally, the it is the shell in which you type in a command like "mv /home/demo1/* /home/demo2" that replaces the * and other wildcard characters with whatever it should be replaced with.
When you call a command directly from Java, not through the Unix shell, it will tell the command to literally look for a file named *. That file doesn't exist, so it doesn't work.
There are better ways to move files from one directory to another. You can do this with the rename() method in class java.io.File, for example.