write to file and preserve accents and umlauts
I have an xml file, that I want to read and write different
output files for. I do not want use xml feature, just want
to separate the large input file in smaller output files.
Problem: the output text has things like "? " instead
of accented texts (i.e. passť appears like pass?).
I use eclipse, and the text in the console output, via
System.out.println(...) appears correct!
I tried to set the CharSet, but with no success.
Here is the relevant code part:
fi = new FileInputStream(dat);
is = new InputStreamReader(fi);
bufRd = new BufferedReader(is);
String sChSetOut = is.getEncoding(); // = "Cp1252"
fo = new FileOutputStream(datOut);
os = new OutputStreamWriter(fo, sChSetOut);
fWrt = new BufferedWriter(os);
line = bufRd.readLine();
// do the selection of the output file ...
fWrt.newLine(); // text in file lost accents and umlatus
// Echo written lines:
System.out.println(line); // text appears correct with accents
Thanks for help
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL