Java examples for java.io:File UTF
Gets default file encoding
//package com.java2s; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { /**//from w w w .ja v a 2 s . com * Gets default encoding * * @return Default Encoding */ public static String getDefaultEncoding() { String encoding = System.getProperty("file.encoding"); if (encoding == null) { try { File file = File.createTempFile("temp", null); FileWriter writer = new FileWriter(file); encoding = writer.getEncoding(); writer.close(); file.deleteOnExit(); } catch (IOException e) { encoding = "US-ASCII"; } } return encoding; } }