Character encoding
Character encoding levert bij de uitwisseling tussen verschillende systemen problemen op. Linux, AIX en Sun Solaris gedragen zich anders.
De commando's file en enca
Contents
checks 1
So if I compile this, we can check.
public class CharSetTest { public static void main(String[] args) { System.out.println("Default Charset=" + Charset.defaultCharset()); System.setProperty("file.encoding", "Latin-1"); System.out.println("file.encoding=" + System.getProperty("file.encoding")); System.out.println("Default Charset=" + Charset.defaultCharset()); System.out.println("Default Charset in Use=" + getDefaultCharSet()); } private static String getDefaultCharSet() { OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream()); String enc = writer.getEncoding(); return enc; } }
check 2
try this simple program import java.io.FileWriter; import java.io.IOException; public class Test { public static void main(String args[]) throws IOException { FileWriter filewrt = new FileWriter("out"); String defaultcharset = filewrt.getEncoding(); filewrt.close(); System.out.println("Default encoding is :" + defaultcharset); } }
check 3
import java.io.FileWriter; import java.io.IOException; import java.util.Locale; public class Test { public static void main(String args[]) throws IOException { FileWriter filewrt = new FileWriter("out"); String defaultcharset = filewrt.getEncoding(); filewrt.close(); System.out.println("Default encoding is :" + defaultcharset); Locale locale = Locale.getDefault(); System.out.println(locale); } }
check 4
this is teh program that i run on test import java.io.BufferedWriter; import java.io.FileWriter; public class FileWrite { public static void main(String args[]) { try { // Create file FileWriter fstream = new FileWriter("out.txt"); BufferedWriter out = new BufferedWriter(fstream); out.write("Damásio Pinto Do Carmo"); // Close the output stream out.close(); } catch (Exception e) {// Catch exception if any System.err.println("Error: " + e.getMessage()); } } }