Tuesday, November 11, 2008

Convert String to InputStream

If you want to create InputStream from String in Java, the following code might help.

String text = "simple string";
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( text.getBytes());

Since ByteArrayInputStream is a concrete class extends from InputStream, you can instantiate it using the new keyword and use it in place where InputStream is expected i.e. use it as an argument passed to another method.

4 comments:

  1. This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb.
    This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolites festivity to pity. I appreciated what you ok extremely here 


    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  2. Thanks For sharing a nice post about all Course.It is very helpful and for us.
    Workday training in bangalore

    ReplyDelete