Java BufferedInputStream Create getInputStream(String string)

Here you can find the source of getInputStream(String string)

Description

Get an InputStream for the String.

License

Open Source License

Parameter

Parameter Description
string the String.

Return

the InputStream.

Declaration

public static InputStream getInputStream(String string) 

Method Source Code


//package com.java2s;
import java.io.BufferedInputStream;

import java.io.ByteArrayInputStream;

import java.io.InputStream;

import java.io.UnsupportedEncodingException;

public class Main {
    public static final String ENCODING_UTF8 = "UTF-8";

    /**//from   w w  w .  j a v a  2  s .  c  om
     * Get an InputStream for the String.
     *
     * @param string the String.
     * @return the InputStream.
     */
    public static InputStream getInputStream(String string) {
        try {
            return new BufferedInputStream(new ByteArrayInputStream(string.getBytes(ENCODING_UTF8)));
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related

  1. getInputStream(File file)
  2. getInputStream(final String path)
  3. getInputStream(InputStream in)
  4. getInputStream(String path)
  5. getInputStream(String resource)
  6. getInputstreamForZipEntry(ZipFile zipFile, String uri)
  7. getInputStreamFromEncodedStr(String encodedDetails)
  8. getInputStreamFromString(String _string)
  9. getInputStreamFromString(String _string)