import java.io.*;
public class WriterTxt{
public static void main(String[] args) throws IOException{
writeToTxt("D:/test1.txt");
}
public static void writeToTxt(String toTxt)throws IOException{
PrintStream console = System.out;
PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(toTxt)));
System.setOut(out);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = "hello world!世界您好!";
System.out.println(s);
out.close();
System.setOut(console);
}
}