Java BufferedInputStream Create getStream(final String string, final String codePage)

Here you can find the source of getStream(final String string, final String codePage)

Description

Get inputstream from string

License

Open Source License

Parameter

Parameter Description
string the string to convert
codePage the codepage of string

Exception

Parameter Description
UnsupportedEncodingException an exception

Return

an inputstream

Declaration

public static InputStream getStream(final String string,
        final String codePage) throws UnsupportedEncodingException 

Method Source Code

//package com.java2s;
/*/*from   www  . jav a 2s  . com*/
 * This work is Open Source and licensed by the European Commission under the
 * conditions of the European Public License v1.1 
 *  
 * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); 
 * 
 * any use of this file implies acceptance of the conditions of this license. 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 * License for the specific language governing permissions and limitations 
 * under the License.
 */

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

public class Main {
    /**
     * Get inputstream from string
     * @param string the string to convert
     * @param codePage the codepage of string
     * @return an inputstream
     * @throws UnsupportedEncodingException
     */
    public static InputStream getStream(final String string,
            final String codePage) throws UnsupportedEncodingException {
        return new ByteArrayInputStream(string.getBytes(codePage));
    }
}

Related

  1. getInputStreamFromString(String _string)
  2. getInputStreamFromString(String input)
  3. getInputStreamFromString(String s)
  4. getStream(byte[] bytes)
  5. getStream(final File file)
  6. getStream(InputStream is)
  7. getStream(String name)
  8. getStream(String resource)
  9. getStream(String string)