黑马程序员技术交流社区
标题:
怎样使用PrintSteam呢?
[打印本页]
作者:
任亚俊
时间:
2013-12-23 17:01
标题:
怎样使用PrintSteam呢?
本帖最后由 任亚俊 于 2013-12-23 22:06 编辑
我知道可以用PrintSteam打印内容到控制台,但具体怎么实现呢?如下:
PrintStream myOut;
myOut = new PrintStream("D:\\hello.txt");
myOut.println("Hello World!");
复制代码
上面代码把Hello World输出到了hello.txt中,怎样构造PrintSteam对象,才能让Hello World输出到控制台呢?
作者:
Kyle
时间:
2013-12-23 17:40
把路径名改成System.out就行了,意思是成为标准的输出流,即控制台输出。
public class Test {
public static void main(String[] args) throws IOException {
PrintStream myOut;
myOut = new PrintStream(System.out);
myOut.println("Hello World!");
}
}
复制代码
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2