Hi,
On 24 Mai, 09:29, Usama007 <[email protected]> wrote: > Hi guys, > I wanna ask a question about file streaming that I hope I find an > answer > when creating a txt file and write data to it, I found that it is > "ANSI" encoded by default.Even if I write a "Unicode" stream. > like that: > File EMAC=new File("D:\\test\\License.txt"); // License.txt initially > is not exist, so it is created at this step > FileOutputStream fos = new FileOutputStream(EMAC); > Writer out = new OutputStreamWriter(fos, "UNICODE"); I have not changed the encoding, but looking up the javadoc for OutputStreamWriter, I found the constructor: http://java.sun.com/j2se/1.4.2/docs/api/java/io/OutputStreamWriter.html#OutputStreamWriter(java.io.OutputStream,%20java.lang.String) OutputStreamWriter public OutputStreamWriter(OutputStream out, String charsetName) throws UnsupportedEncodingException Create an OutputStreamWriter that uses the named charset. Parameters: out - An OutputStream charsetName - The name of a supported charset Throws: UnsupportedEncodingException - If the named encoding is not supported and following the link for charsetName lists the following encodings Standard charsets Every implementation of the Java platform is required to support the following standard charsets. Consult the release documentation for your implementation to see if any other charsets are supported. Charset Description US-ASCII Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set ISO-8859-1 ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 UTF-8 Eight-bit UCS Transformation Format UTF-16BE Sixteen-bit UCS Transformation Format, big-endian byte order UTF-16LE Sixteen-bit UCS Transformation Format, little-endian byte order UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark Perhaps you can try UTF-8 instead of "UNICODE" There is also a System Property with which you can set the encoding. Something like file.encoding HTH Ewald --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
