Vista时代的到来,DOS还有用吗,命令行还有用吗?当然!
对于任意win下的程序,在命令行中就支持输出重定向.
比如在cmd下输入ping 127.0.0.1 >> c:\test.txt
控制没有任何输出?!
去看看c盘下的test.txt
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
这就是重定向操作符">>"的作用
1 public class TestWinCon {
2 /**
3 * @param args
4 */
5 public static void main(String[] args) {
6 System.out.println("haha");
7 }
8 }
9
cmd下执行
java TestWinCon >>aa.txt
会在本目录下生成aa.txt
内容就是
haha
posted on 2007-01-03 15:47
交口称赞 阅读(3510)
评论(6) 编辑 收藏 所属分类:
java相关