Returns a new encoding reader for the given stream and javaEncoding.

@param is the input stream providing the bytes.
@param javaEncoding the JDK name for the encoding.

@return an encoding reader or null for ISO-8859-1.
439929
public Reader create(InputStream is)
    throws UnsupportedEncodingException
  {
    Reader reader = create(is, getJavaEncoding());

    if (reader != null)
      return reader;
    else
      return new ISO8859_1Reader(is);
  }
1080285
public static Writer createWriter(OutputStream outputStream,String encoding)
    {
        //get encoding
        String updatedEncoding=IOHelper.getEncodingToUse(encoding);
        
        //create writer
        Writer writer=null;
        try
        {
            writer=new OutputStreamWriter(outputStream,updatedEncoding);
        }
        catch(UnsupportedEncodingException exception)
        {
            throw new FaxException("Unable to create writer, unsupported encoding: "+encoding,exception);
        }
        
        return writer;
    }
810726
public <V> V convertFrom(final InputStream in) {
        if (in == null) return null;
        return (V) new AnyDecoder(factory).convertFrom(new JsonStreamReader(in));
    }
503253
byte[] encodeLikeABoss(final byte[] input) {

        if (input == null) {
            throw new NullPointerException("input");
        }

        final byte[] output = new byte[input.length << 1];

        int index = 0; // index in output
        for (int i = 0; i < input.length; i++) {
            String s = Integer.toString(input[i] & 0xFF, 16);
            if (s.length() == 1) {
                s = "0" + s;
            }
            output[index++] = (byte) s.charAt(0);
            output[index++] = (byte) s.charAt(1);
        }

        return output;
    }
1071425
public static byte[] getBytes(String string, String encoding) {
        try {
            return string.getBytes(encoding);
        } catch(UnsupportedEncodingException e) {
            throw new IllegalArgumentException(encoding + " is not a known encoding name.", e);
        }
    }
1059432
public static Reader getInputStreamReader(InputStream in, String charset) {
    try {
      return new InputStreamReader(in, charset);
    }
    catch (UnsupportedEncodingException ex) {
      throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec
    }
  }
622770
public static StreamDecoder forInputStreamReader(InputStream in,
                                                     Object lock,
                                                     String charsetName)
        throws UnsupportedEncodingException
    {
        String csn = charsetName;
        if (csn == null)
            csn = Charset.defaultCharset().name();
        try {
            if (Charset.isSupported(csn))
                return new StreamDecoder(in, lock, Charset.forName(csn));
        } catch (IllegalCharsetNameException x) { }
        throw new UnsupportedEncodingException (csn);
    }
930148
public BufferedReader getReader()
    	throws UnsupportedEncodingException
    {
        if (_inputState!=0 && _inputState!=2)
            throw new IllegalStateException();
        if (_reader==null)
        {
            String encoding=getCharacterEncoding();
            if (encoding==null)
                encoding=StringUtil.__ISO_8859_1;
            _reader=new BufferedReader(new InputStreamReader(getInputStream(),encoding));
            
        }
        _inputState=2;
        return _reader;
    }
465191
public static byte[] decode(InputStream in) {
        try {
            return IOUtils.toByteArray(decodeToStream(in));
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
973085
public static String inputStream2String(final InputStream is, final String charsetName) {
        if (is == null || isSpace(charsetName)) return null;
        try {
            return new String(inputStream2Bytes(is), charsetName);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
    }
1344501
public static String getPostString(InputStream is, String encoding) {
        try {
            StringWriter sw = new StringWriter();
            IOUtils.copy(is, sw, encoding);

            return sw.toString();
        } catch (IOException e) {
            // no op
            return null;
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
1249448
public String getEncodingByMimeType(String type)
    {
        String encoding =null;

        if (type!=null)
            encoding=(String)_encodingMap.get(type);

        return encoding;
    }
274734
public static String readStreamToString(InputStream is, String encoding) throws IOException {
		try {
			StringBuilder sb = new StringBuilder();
			byte[] buf = new byte[1024 * 10];
			int read;
			while ((read = is.read(buf)) >= 0) {
				sb.append(new String(buf, 0, read, encoding));
			}
			return sb.toString();
		} finally {
			is.close();
		}
	}
536617
@Nullable
    public final Charset getEncoding() {
        final String parameter = getParameter(ENCODING);
        if (parameter == null) {
            return null;
        }
        return Charset.forName(parameter);
    }
1042625
public static String getInputStreamAsString(InputStream is) throws IOException {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ReadableByteChannel rbch = Channels.newChannel(is);
		WritableByteChannel wbch = Channels.newChannel(baos);
		fastChannelCopy(rbch, wbch);
		rbch.close();
		wbch.close();
		return new String(baos.toByteArray(), Charset.forName("UTF-8"));
	}
945675
public static InputStream toInputStream(CharSequence input, Charset encoding) {
        return toInputStream(input.toString(), encoding);
    }
1345866
public static boolean isRecognizedEncoding(String encoding)
    {
        EncodingInfo ei;

        String normalizedEncoding = encoding.toUpperCase();
        ei = (EncodingInfo) _encodingTableKeyJava.get(normalizedEncoding);
        if (ei == null)
            ei = (EncodingInfo) _encodingTableKeyMime.get(normalizedEncoding);
        if (ei != null)
            return true;
        return false;
    }