Java acquisition server system default encoding format

Big brother to teach, to be a note 

// Spring Management acquired requets.attributes
ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes ();
IF (attrs == null) {
// the throw new new IllegalStateException ( "does not exist in the current thread context Request ");
} the else {
// sources
the Properties System.getProperties = Properties ();
// Get real entry path ( '... / the webapps' + '/images/testLog.txt')
String logRealPath = attrs. . getRequest () GetServletContext () the getRealPath ( "/ Images / testLog.txt");.
// open stream
the OutputStream new new OUT = a FileOutputStream (logRealPath, to true);
// get system information
Set <Map.Entry <Object, Object = entries It properties.entrySet >> ();
// print to file them
for (Map.Entry entry:entries
) {
Out.write (entry.getKey () toString () the getBytes ( "UTF-. 8"));..
Out.write ( "->" the getBytes ( "UTF-. 8."));
Out.write ( . entry.getValue () toString () the getBytes ( "UTF-. 8"));.
out.write ( "\ n-" .getBytes ( "UTF-. 8"));
}

// close the flow
the out.close ();
}

// browser and enter the project path /images/testLog.txt view
to find "file.encoding"


Guess you like

Origin www.cnblogs.com/zou-rong/p/11006187.html