D-D
D-D

Reputation: 966

How to handle classCastException

Can not we convert a string object to a byte object?

public bitmap a(String s){
   byte[] b=(byte[])getValue(s);
   ...
}

getValue returns a string object.

Upvotes: 0

Views: 746

Answers (1)

Dan D.
Dan D.

Reputation: 32391

Use String.getBytes() and its overloaded versions to transform a String to byte[].

There are overloaded versions that allow you to specify the charset like UTF-8 for instance:

getBytes(String charsetName);

Upvotes: 4

Related Questions