Write the log file through Java, the implementation of line wrapping:
Provides methods for writing log files:
/**
* Write log file
* @param string
* @param file
*/
public static void Writelogfile (string string, file file) {
FileWriter FW = NULL;
try {
FW = new FileWriter (file);
Fw.write (string);
catch (IOException e) {
E.printstacktrace ();
Logger.error ("Filewrutil.writelogfile (string string, file file) occur error:" +e.getmessage ());
finally {
try {
Fw.close ();
FW = NULL;
catch (IOException e) {
E.printstacktrace ();
Logger.error ("Filewrutil.writelogfile (string string, file file) occur error:" +e.getmessage ());
}
}
}
The log content in the method string is done by stringbuffer stitching, so the document can be wrapped by stitching the following code each time the file is StringBuffer:
Buffer.append (System.getproperty ("Line.separator"));