200分!!! 很简单的问题 只能做到这步了。Runtime.getRuntime().exec("c:\\winnt\\system32\\cmd.exe /c dir ");后一步不知该如何做了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*;class PT{ public static void main(String[] args) throws IOException { String filename="out.txt"; if(args.length>0){ filename=args[0]; } String command="cmd /C dir"; Runtime r=Runtime.getRuntime(); Process p=r.exec(command); BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream())); PrintStream ps=new PrintStream(new FileOutputStream(filename)); String inline; while(null!=(inline=br.readLine())){ ps.println(inline); } System.out.println("a command result has been readed to a file "+filename); }}另外,看看这个:http://expert.csdn.net/Expert/topic/1122/1122963.xml?temp=.7517206 cmd /C dir > c:\\temp.txt cmd 后面的/c 表示什么意思? 不用写到文件中再读出来这么麻烦吧,Process有重定向流啊,直接读不就行了。 namowen(寒号不已) 果然厉害 http://expert.csdn.net/Expert/topic/1133/1133264.xml?temp=.6162989 电梯调度算法模拟的实现 求jsp源代码 j2ee,tomcat,myeclipse怎么连起来啊 请问字符为空的条件怎么写? 怎样得到table中的一个列的所有数据? 100分求方案,高手请进,如何实现B/S模式下进行照片采集,大家给些建议吧 有那位大哥帮一下妹妹呀!急救!帮帮MM! Eclipse的问题,请高手指点 请帮忙! 关于线程池的一点问题(实习生) 大家进来聊聊吧!!! 我在做一个项目,要用到OJB(ObJectRelationalBridge ),哪位兄弟知道这个东东是怎么用的?有什么相关的资料?
class PT
{
public static void main(String[] args) throws IOException
{
String filename="out.txt";
if(args.length>0){
filename=args[0];
}
String command="cmd /C dir";
Runtime r=Runtime.getRuntime();
Process p=r.exec(command);
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
PrintStream ps=new PrintStream(new FileOutputStream(filename));
String inline;
while(null!=(inline=br.readLine())){
ps.println(inline);
}
System.out.println("a command result has been readed to a file "+filename);
}
}
另外,看看这个:
http://expert.csdn.net/Expert/topic/1122/1122963.xml?temp=.7517206