Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

Wednesday, May 21, 2008

Java String to byte array and InputStream

Based on Google result, the best solutions are
byte[] byteArray = yourString.getBytes(charsetName);

and
InputStream stream = new ByteArrayInputStream(yourString.getBytes(charsetName));