N
N
Nchar2015-04-14 13:19:46
Java
Nchar, 2015-04-14 13:19:46

How to write a Russian string in UTF-8 and/or cp1251 to a file?

The Russian string that needs to be written to the file is stored directly in the code:
String someValue = "Поехали!";
I tried to write to the file like this:

BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(new FileOutputStream(targetFilePath))
);        
bw.write(someValue + "\n");
bw.close();
The result in notepad (notepad.exe) is:
???????!

I tried to use different encodings (utf-8, utf-16, cp1251) in the OutputStreamWriter constructor, but I did not see the Russian text. I tried to watch in different encodings through Sublime and EditPad Lite, I don’t see Russian either.
How to save the Russian text specified in the code to a file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SpyceR, 2015-04-14
@nikitakuhta

rsdn.ru/forum/java/2128031.hot
citforum.ru/internet/javascript/java_rbint.shtml

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question