Java InputStream Create InputStreamFromString(String str)

Here you can find the source of InputStreamFromString(String str)

Description

Input Stream From String

License

Apache License

Declaration

public static InputStream InputStreamFromString(String str) 

Method Source Code


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

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

public class Main {
    private static final String ENCODING = "UTF8";

    public static InputStream InputStreamFromString(String str) {
        byte[] bytes = null;
        ByteArrayInputStream thisInputStream = null;

        try {/*w  w  w  .  j av a 2  s.  co  m*/
            bytes = str.getBytes(ENCODING);
            thisInputStream = new ByteArrayInputStream(bytes);
        } catch (Exception e) {

        }

        return thisInputStream;
    }
}

Related

  1. inputStream(final File file)
  2. inputStream(final String in)
  3. inputStream(String fileName)
  4. inputStream(String path)
  5. inputStreamFromPath(String path)
  6. newInputStream(Class clazz, String filename)
  7. newInputStreamReader(InputStream is)
  8. toInputStream(byte[] bytes)
  9. toInputStream(byte[] data)