Here you can find the source of toInputStream(final String string, final Charset charset)
Parameter | Description |
---|---|
string | the string to use. |
charset | the charset to use. |
public static InputStream toInputStream(final String string, final Charset charset)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.Charset; public class Main { /**/* w w w. j a v a 2 s. c om*/ * Build an input stream from the specified string in the encoding specified. * @param string * the string to use. * @param charset * the charset to use. * @return the input stream. */ public static InputStream toInputStream(final String string, final Charset charset) { return new ByteArrayInputStream(string.getBytes(charset)); } /** * Build an input stream from the specified string in the default encoding of the JVM. * @param string * the string to use. * @return the input stream. */ public static InputStream toInputStream(final String string) { return toInputStream(string, Charset.defaultCharset()); } }