Java to convert bytes into String
Posted on 2011-02-22
My java application has read a Chinese web page into bytes, and has detected the encoding of the web page.
bytes input = readfileintobyte(File file);
String enc = detectEncoding(input);
How can i convert the input into a "utf-8" encoded string?
I have tried the following but it doesn't work:
String newinput = new String(input, "utf-8");
Seems like that the enc variable should be used to convert to utf-8 string. But how?