Effect of the PrintWriter () is to define the location of the output stream, and this stream may be a normal memory Chinese, reducing output distortion. Example:
the PrintWriter the PrintWriter new new OUT = (the OutputStreamWriter new new (new new a FileOutputStream ( "D: /text.txt"), "UTF-. 8")); // define the location of the output stream, and the file must exist
out.println ( "Chinese Test "); // write to
out.close (); // close the stream
Note: The file stream must be promptly used up by close method to close, otherwise it will stay open until the program is stopped, increase the burden on the system
new StringWriter()
StringWriter sw = new StringWriter();