java runtime.exec()命令不能执行
importjava.io.IOException;publicclassCmd{publicstaticvoidmain(String[]args){try{Runti...
import java.io.IOException; public class Cmd { public static void main(String[] args){ try{ Runtime runtime=Runtime.getRuntime(); String[] cmd={"cmd/c\\","copy"+" ","D:/stock.xml"+" "," D:/backupStock.xml"}; runtime.exec(cmd); }catch (IOException e){ e.getStackTrace(); } } }
展开
展开全部
import java.io.IOException; import java.io.*; public class io { public static void main(String[] args){ try{ Runtime runtime=Runtime.getRuntime(); // 这里一定要是这样的双斜线 String cmd="cmd /c copy D:\\stock.xml D:\\backupStock.xml"; runtime.exec(cmd); }catch (IOException e){ e.getStackTrace(); } } } 给你修正过了
展开全部
at first time ,you must goto these files's path
but your command is
cmd/c\copy D:/stock.xml D:/backupStock.xml
it's not right! so you fail
so I think it's must be like this
cmd/c copy D:\stock.xml D:\backupStock.xml
it's none of java runtime exec() 's business...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |