Java InputStream Read by Charset createInput(String s, String charsetName)

Here you can find the source of createInput(String s, String charsetName)

Description

create Input

License

Open Source License

Declaration

public static InputStream createInput(String s, String charsetName) 

Method Source Code


//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 {
    public static InputStream createInput(String s, String charsetName) {

        Charset cs = Charset.forName(charsetName);
        InputStream in = new ByteArrayInputStream(cs.encode(s).array());
        return in;

    }/*from  www  . j  a v  a2 s. c o  m*/
}

Related

  1. convertEncoding(Charset output_charset, String input_string)
  2. convertFromUnicode(String input, String targetCharset)
  3. convertStreamToString(final InputStream is, final Charset charset)
  4. convertToCharacterSet(byte[] input, Charset fromCharset, Charset toCharSet)
  5. copyToString(InputStream in, Charset charset)
  6. createZipInputStream(InputStream inStream, Charset charset)
  7. forceEncoding(String inputString, String targetCharset)
  8. fromUnicode(String charset, String input)
  9. getContentFromInputStream(InputStream in, String charset)