有两种方法1.调用系统命令。
2.完全靠java实现:java中没有现成的方法,只能自己遍历整个目录结构,然后一个个的拷贝。
2.完全靠java实现:java中没有现成的方法,只能自己遍历整个目录结构,然后一个个的拷贝。
解决方案 »
- 为什么在java.sql里没有BaseQuery,我用的是JDK 1.6
- 输出两个数组的相同元素(用最优算法)
- java编程思想第二版和第四版的有些什么区别?谢谢回答
- 何时使用多线程??
- IO流问题,大哥们救命!
- 把某个服务器短运行的jar反编译过来的源码(大概有上百个文件),经过自己的修改后打jar包能否和原来的jar一样能正常运行? 今天揭帖.
- 求大神看看这个程序是怎么了?编译没错,但是运行结果出错
- Java集合List的排序
- C++ TO JAVA请大家推荐几本好书!
- && & 的问题,某些时候它们似乎没区别。
- 反编java
- 那儿可以下载com.sun.image.codec.jpeg.*包(无内容)
String com[] = new String[3];
com[0] = "copy";
com[1] = "c:\\temp";
com[3] = "2:\\temp";
rt.exec(com);
Runtime rt = Runtime.getRuntime();
String com[] = new String[3];
com[0] = "copy";
com[1] = "c:\\winzip.log";
com[2] = "d:\\winzip.log";
rt.exec(com);系统提示错误:
java.io.IOException:CreateProcess:copy c:\winzip.log d:\winzip.log error=2
请大家帮帮忙
Runtime rt = Runtime.getRuntime();
String com[] = new String[3];
com[0] = "copy";
com[1] = "c:\\winzip.log";
com[2] = "d:\\winzip.log";
rt.exec(com);系统提示错误:
java.io.IOException:CreateProcess:copy c:\winzip.log d:\winzip.log error=2
请大家帮帮忙
{
public static void main(String[] args) throws Exception
{
run(args);
} public static void run(String[] cmds) throws Exception
{
String s = "cmd /c";
for(int i=0;i<cmds.length;i++)
{
s+=" ";
s+=cmds[i];
}
Process proc=Runtime.getRuntime().exec(s);// System.out.println("result:");
BufferedReader stdout = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
String str;
while((str=stdout.readLine())!=null)
{
System.out.println(str);
}
stdout.close();
// System.out.println("\nerror:");
BufferedReader stderr = new BufferedReader(
new InputStreamReader(proc.getErrorStream()));
while((str=stderr.readLine())!=null)
{
System.out.println(str);
}
stderr.close();
}
}注意其中的cmd /c
{
public static void main(String[] args) throws Exception
{
run(args);
} public static void run(String[] cmds) throws Exception
{
String s = "cmd /c";
for(int i=0;i<cmds.length;i++)
{
s+=" ";
s+=cmds[i];
}
Process proc=Runtime.getRuntime().exec(s);// System.out.println("result:");
BufferedReader stdout = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
String str;
while((str=stdout.readLine())!=null)
{
System.out.println(str);
}
stdout.close();
// System.out.println("\nerror:");
BufferedReader stderr = new BufferedReader(
new InputStreamReader(proc.getErrorStream()));
while((str=stderr.readLine())!=null)
{
System.out.println(str);
}
stderr.close();
}
}注意其中的cmd /c