Reputation: 3
In java desktop application my I have used cut button;when it's clicked there should occur cut operation.In this code there is not generated wrong message.but when I run the project it shows that cut process has been proceed.But it does not work correctly,my code is given below: // For cut
String sourceLocation= "";
String destLocation="";
String fileCopyCmd="";
Process shortcutCpyprs=null;
sourceLocation="E:\\data.txt";
destLocation="G:\\";
fileCopyCmd="cut \"" + sourceLocation + "\" \"" + destLocation + "\"";
System.out.println(fileCopyCmd);
try {
shortcutCpyprs = Runtime.getRuntime().exec(new String[]{"cmd", "/c", fileCopyCmd});
} catch (IOException ex) {
Logger.getLogger(DesktopApplication2View.class.getName()).log(Level.SEVERE, null, ex);
}
Upvotes: 0
Views: 1603
Reputation: 18119
Why don't you use https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/FileUtils.html#moveFile(java.io.File,%20java.io.File) ?
Using Java for such operations will give you access to any exceptions that could occur.
Upvotes: 1