Create UTF8 InputStream


import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

public class Util{

    public static InputStream toUTF8InputStream(String str) {
        InputStream is = null;
        try {
          is = new ByteArrayInputStream(str.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
          // UTF-8 should always be supported
          throw new AssertionError();
        }
        return is;
      }
}
Home 
  Java Book 
    Runnable examples  

IO ByteArrayInputStream:
  1. Create ByteArrayInputStream from a String
  2. Create UTF8 InputStream
  3. Convert to byte array