Hi friends

i'm trying to write my own language in a file (using RandomAccessFile and sometimes fileOutputStream classes of API) but i can't use Farsi in these files , beacuse they are not unicode and instead of characters , the Elements of them are Bytes , what do you suggest me handling this problem ??

Recommended Answers

All 2 Replies

Have you tried using the following?

Writer out   = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("someFile")));

If your default encoding will not work correctly, you can specify encoding on the OutputStreamWriter (UTF-8 probably) by using the constructor that accepts a charset parameter.

If your default encoding (in Java, determined by your own system settings) works fine for Farsi, you can use the easier form of the writer:

Writer out = new BufferedWriter(new FileWriter("someFile"));

thank you very much , i tested your idea , and fortunately , it worked , really really thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.