分类: WINDOWS
2011-07-23 09:46:19
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
这就是重定向操作符">>"的作用
cmd下执行
java TestWinCon >>aa.txt
会在本目录下生成aa.txt
内容就是
haha