Hello
how change charset for this string from cp1250 (Windows) to UTF-8
all Program in java is default running in UTF-8
File f = new File("C:/myfile.txt);
FileReader rd = new FileReader(f);
System.out.println("GET - encoding: " + rd.getEncoding()); /* this is
always utf-8 why?*/
char[] buf = new char[(int)f.length()];
rd.read(buf);
return new String(buf).replaceAll("[\n\r]*", "");
myfile is charset cp1250
how change String from cp1250 to utf 8 ?
regards
Rafal
Joshua Cranmer - 15 Apr 2007 20:03 GMT
> Hello
>
[quoted text clipped - 15 lines]
> regards
> Rafal
From the API for java.io.FileReader:
The constructors of this class assume that the default character
encoding and the default byte-buffer size are appropriate. To specify
these values yourself, construct an InputStreamReader on a FileInputStream.
So your second line would be:
InputStreamReader rd = new InputStreamReader(new FileInputStream(f),
"cp1250");
("cp1250" or "Cp1250"? I don't actually know.)