1

I am converting byte array to String by:

public static String byteArrayToString(byte[] bytes)
{
    return new String(bytes);
}

But this approach is taking much time. Is there any efficient way to convert byte array to String?

2 Answers 2

6

There is no better way that I know of. And you should always use the constructor that takes the encoding with it, or its pretty much guaranteed that you'll end up with screwed up characters if you deal with any language other than english. ie: you really should be using new String(bytes, "UTF-8") (obviously replacing UTF-8 by whatever encoding your byte[] is using to represent the text).

Sign up to request clarification or add additional context in comments.

Comments

0
String head=new String(byteArray, "ISO-8859-1");

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.