java的IO求解:以下代码字符串1重定向到了out.txt,但是2为什么没在控制台打印输出呢???
FileOutputStreamfos=newFileOutputStream("D:/out.txt");BufferedOutputStreambos=newBuff...
FileOutputStream fos = new FileOutputStream("D:/out.txt");
BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);
PrintStream ps = new PrintStream(bos, false);
System.setOut(ps);
System.out.println("1");
PrintStream ps2 = System.out;
System.setOut(ps2);
System.out.println("2");
ps.close();
ps2.close(); 展开
BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);
PrintStream ps = new PrintStream(bos, false);
System.setOut(ps);
System.out.println("1");
PrintStream ps2 = System.out;
System.setOut(ps2);
System.out.println("2");
ps.close();
ps2.close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询