Printstream out=new PrintStream(new BufferOutputStream(new FileOutputStream("t.txt")));
system.setOut(out);
system.setOut(out);
我记得以前有人答过的,就是这个样子的,我是借花献佛
system.setOut(out);
system.setOut(out);
我记得以前有人答过的,就是这个样子的,我是借花献佛
调试欢乐多
要不你就不要显示输出到屏幕,直接到文件,不可以吗?
import java.io.*;public class fileio{
public static void main(String[] args) throws IOException
{
String hello="hello";
FileOutputStream out=null;
out=new FileOutputStream("a.dat");
if(out!=null)
{
System.out.println("Begin to write to a file called a.dat");
for(int i=0;i<hello.length();i++)
out.write((int)hello.charAt(i));
System.out.println("Write string "+hello);
out.close();
}
}
}
system.setOut(out);
这句不明白。方法的参数out是不是就是输出的内容。
你说以前有人答过,我找了找,可没找到。
大概啥时候的?
PrintStream pStream;
try
{
fOutStream = new FileOutputStream(new File("e:\\c.txt"));
pStream = new PrintStream(fOutStream);
System.setOut(pStream);
}catch(IOException e)
{
}
这样你想输出的内容就可以输出到e:\c.txt里边去了.