-2

Possible Duplicate:
Encoding conversion in java

Actually I need an example, method to convert from cp1251 encoding to utf-8 in Java. For example, I don't have a headache in PHP with this question because of:

iconv($str, "cp1251", "utf-8");

So, may be someone had an experience to make these kind of things in Java, please help. Thx in advance.

Community
  • 1
  • 1
Arthur Kushman
  • 3,449
  • 10
  • 49
  • 64
  • I hate the communities like kamaci, Wooble, TryTryAgain, Mark, alfasin - this kills all social sites like SO. The most useful answer is the method (program) that solves it, and why some people could just delete my adequate comments?! I don't want it, nobody does. And pals -3 for what, for "dublicate"? Are U insane? Oh sorry, I'd forgot that Your points achieved by nothing at all. – Arthur Kushman Aug 27 '12 at 07:38

1 Answers1

6

As opposed to PHP, strings in Java have no inherent byte-level encoding. They are native UTF-16 strings. So if you want a file re-encoded, just read it with one encoding and write with the other. Check out InputStreamReader and OutputStreamWriter.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436