Create ByteArrayInputStream from a String


import java.io.ByteArrayInputStream;

public class Main {
  public static void main(String[] argv) throws Exception {

    byte[] bytes = "asdf".getBytes("UTF8");
    new ByteArrayInputStream(bytes);
  }
}
Home 
  Java Book 
    Runnable examples  

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