Answer the question
In order to leave comments, you need to log in
How to fix Cyrillic encoding in android?
Hello, I can’t understand why this code for reading a previously created file in the internal android system displays something incomprehensible in places of the Russian language =>
try {
FileInputStream fileInputStream = context.openFileInput(fileIniInfo);
int ch;
StringBuffer result = new StringBuffer();
while((ch = file.read()) != -1) {
result.append((char)ch);
}
return result.toString();
} catch (IOException e) {
e.printStackTrace();
}
{"fullName":"ÃÂÃÂøòõàüøÃÂ", "id":"0", "countEnter":1}
try {
FileOutputStream fileOutputStream = context.openFileOutput(fileIniInfo, Context.MODE_PRIVATE);
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fileOutputStream, "utf8"));
String result = object.toString();
wr.write(result);
wr.close();
} catch (IOException e) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
Solved the problem by rewriting the file open method, now it looks like this =>
BufferedReader br = new BufferedReader(new InputStreamReader(file));
return br.readLine(); // В данном случае мой файл будет всегда в одну строку!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question