Convert string into InputStream using ByteArrayInputStream class. : ByteArrayInputStream « File Input Output « Java






Convert string into InputStream using ByteArrayInputStream class.

   

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

public class Main {
  public static void main(String[] args)throws Exception {
    String text = "Converting String to InputStream Example";
    InputStream is = new ByteArrayInputStream(text.getBytes("UTF-8"));
  }
}

   
    
    
  








Related examples in the same category

1.Byte Array IO
2.Demonstrate ByteArrayInputStream
3.ByteArrayInputStream Reset
4.Read ByteArrayInputStream to String
5.ByteArrayInputStream implementation that does not synchronize methods.
6.Fast Multi ByteArrayInputStream