I am trying to take a string encoded and saved in Cp1252 encoding and display it in a java text area. When i read it back it has black diamonds with question marks where special characters normally are (', &, etc). What should i do to format it to display the proper characters.
I cant copy and paste the text as it displays almost properly when moved out of word. But the code i am using to read the Cp1252 file is below:
try {
br = new BufferedReader(new FileReader(f));
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
emi.stringContent += "\n" + strLine;
}
br.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(EMailTmpDirRead.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(EMailTmpDirRead.class.getName()).log(Level.SEVERE, null, ex);
}
Thanks!
Made the following edits and now nothing reads in.
StringBuffer temp2 = new StringBuffer(1000);
int numRead = 0;
char[] buf = new char[1024];
try {
ir = new InputStreamReader(new FileInputStream(f), "Cp1252");
while((numRead = ir.read()) != -1)
{
String temp = String.valueOf(buf, 0, numRead);
temp2.append(temp);
buf = new char[1024];
}
emi.stringContent = temp2.toString();
Lines appear to be skipped StringBuffer temp2 = new StringBuffer();
try {
ir = new InputStreamReader(new FileInputStream(f), "Cp1252");
br = new BufferedReader(ir);
while(br.readLine() != null)
{
temp2.append(br.readLine());
}
emi.stringContent = temp2.toString();