Java InputStream Create toInputStream(String input)

Here you can find the source of toInputStream(String input)

Description

to Input Stream

License

Apache License

Declaration

public static InputStream toInputStream(String input) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static InputStream toInputStream(String input) {
        byte[] bytes = input.getBytes();
        return new ByteArrayInputStream(bytes);
    }/*from ww  w  .  ja  v a  2s .  co m*/

    public static InputStream toInputStream(String input, String encoding)
            throws IOException {
        byte[] bytes = (encoding != null) ? input.getBytes(encoding)
                : input.getBytes();
        return new ByteArrayInputStream(bytes);
    }
}

Related

  1. toInputStream(File file)
  2. toInputStream(File file)
  3. toInputStream(final String content)
  4. toInputStream(final String input, final String encoding)
  5. toInputStream(OutputStream out)
  6. toInputStream(String input)
  7. toInputStream(String input, String encoding)
  8. toInputStream(String result, String encoding)
  9. toInputStream(String s, String charSet)