I am trying to read the contents of a file in French (character by character) and check the ascii value to perform some operation. Everything works fine, with the English alphabet, but for a character like éééé, I am facing some problem.
For example, if the contents of my file are français, I get output as franãais. Here, I am attaching my code, please take a look and advise me to fix this problem.
File file = new File("C:\text.txt");
fis = new BufferedInputStream(new FileInputStream(file));
char current;
char org;
while (fis.available() > 0) {
current = (char) fis.read();
int ascii = (int) current;
org = (char) (ascii);
if (ascii == 10) {
resultString = resultString.append(",'"
+ strCompCode + "'");
dbhelpher.addDataRecord(resultString.toString());
resultString.setLength(0);
} else if (ascii != 13) {
resultString.append(org);
}
}
fis.close();
Here I need to read the French char, as it is in the text file. Your advice will be greatly appreciated. Thanks in advance.
source
share