更新时间:2023-12-04 10:48:22
如果你想要绕过System对象。 System.out做了很多额外的事情(例如处理unicode),所以如果你真的只想要原始输出和性能,你实际上甚至可能绕过它。
You could bypass the System object if you want to. System.out does a lot of extra stuff (handling unicode, for instance), so if you really want just the raw output and performance, you actually probably even should bypass it.
import java.io.*;
public class PrintOutTest {
public static void main(String args[]) throws IOException {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream(FileDescriptor.out), "ASCII"), 512);
out.write("test string");
out.write('\n');
out.flush();
}
}
这已在这里。