This function creates and returns a new reader for the
provided input stream.

@param   inputStream
The input stream
@param   encoding
The encoding used by the reader (null for default system encoding)
@return  The reader
544220
public static Reader createReader(InputStream inputStream,String encoding)
    {
        //get encoding
        String updatedEncoding=IOHelper.getEncodingToUse(encoding);
        
        //create reader
        Reader reader=null;
        try
        {
            reader=new InputStreamReader(inputStream,updatedEncoding);
        }
        catch(UnsupportedEncodingException exception)
        {
            throw new FaxException("Unable to create reader, unsupported encoding: "+encoding,exception);
        }
        
        return reader;
    }
204221
public static void consumeInputStream(InputStream inputStream,
            String charsetName, Consumer<String> consumer) {
        try (BufferedReader br = new BufferedReader(
                new InputStreamReader(inputStream, charsetName))) {
            for (String line = br.readLine(); line != null;
                    line = br.readLine())
                consumer.accept(line);
        } catch (IOException e) {
            JMExceptionManager.handleExceptionAndThrowRuntimeEx(log, e,
                    "consumeInputStream", inputStream, charsetName, consumer);
        }
    }
956283
@GwtIncompatible("ByteSink,CharSink")
  public final ByteSink encodingSink(final CharSink encodedSink) {
    checkNotNull(encodedSink);
    return new ByteSink() {
      @Override
      public OutputStream openStream() throws IOException {
        return encodingStream(encodedSink.openStream());
      }
    };
  }
245427
public static BufferedReader getReader(InputStream in, String charsetName) {
		return getReader(in, Charset.forName(charsetName));
	}
932043
public static void copy(final InputStream inputStream, final OutputStream outputStream)
      throws IOException {
    new ByteSource() {
      @Override
      public InputStream openStream() {
        return inputStream;
      }
    }.copyTo(new ByteSink() {
      @Override
      public OutputStream openStream() {
        return outputStream;
      }
    });
  }
107023
public static String readTextFile(InputStream inputStream) {
        InputStreamReader streamReader = new InputStreamReader(inputStream);
        return readTextFile(streamReader);
    }
77104
public static ReadStreamOld openRead(Reader reader)
  {
    if (reader instanceof ReadStreamOld.StreamReader)
      return ((ReadStreamOld.StreamReader) reader).getStream();
    
    ReaderWriterStream s = new ReaderWriterStream(reader, null);
    ReadStreamOld is = new ReadStreamOld(s);
    try {
      is.setEncoding("utf-8");
    } catch (Exception e) {
    }

    return is;
  }
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
    }
  }
1251432
@Override
    public BufferedReader getReader() throws IOException {
        if (this.streamActive) {
            throw new IllegalStateException("InputStream already obtained");
        }
        String enc = getCharacterEncoding();
        if (null == enc) {
            enc = connection.getEncodingUtils().getDefaultEncoding();
        }
        if (null == this.inStream) {
            this.inStream = new RequestBody(this.request.getBody());
        }
        this.inReader = new BufferedReader(
                        new InputStreamReader(this.inStream, enc));
        return this.inReader;
    }
1304943
public static BufferedReader getBufferedReader(final File resource, final String encoding) throws IOException {
		return new BufferedReader(getInputStreamReader(resource, encoding));
	}
265001
@Override
  public Reader create(Reader input) {
    String configuration = null;
    try {
      return create(input, configuration);
    } catch (IOException e) {
      log.debug(e);
      return null;
    }
  }
1075149
public static String readToString(InputStream inputStream, Charset charset) throws IOException {
        return new String(FileCopyUtils.copyToByteArray(inputStream), charset);
    }
506411
public static String read(File file, String encoding) throws IOException {
        Reader reader = getReader(file, encoding);
        String source;
        try {
            source = read(reader);
        } finally {
            reader.close();
        }
        return source;
    }
1158332
public static TextLoader getInstance(Encoding encoding)
	{
		if (null == encoding)
		{
			return getInstance();
		}
		else
		{
			if (!INSTANCE_BY_ENCODING.containsKey(encoding.getIsoName()))
			{
				TextLoader _newInstance = new TextLoader(encoding);
				INSTANCE_BY_ENCODING.put(encoding.getIsoName(), _newInstance);
			}
			return INSTANCE_BY_ENCODING.get(encoding.getIsoName());
		}
	}
324122
public static String readFromInputStream(InputStream inputStream) {
        try {
            return IOUtils.toString(inputStream, Charset.forName("utf-8")).trim();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
1367581
protected BufferedInputStream buffer(final InputStream inputStream) {
        // reject null early on rather than waiting for IO operation to fail
        if (inputStream == null) { // not checked by BufferedInputStream
            throw new NullPointerException("inputStream == null");
        }
        return inputStream instanceof BufferedInputStream ? (BufferedInputStream) inputStream
                : new BufferedInputStream(inputStream);
    }
994525
public Object parse(InputStream inputStream) {
        if (inputStream == null) {
            throw new IllegalArgumentException("inputStream must not be null");
        }

        Object content;
        JsonParser parser = createParser();
        content = parser.parse(inputStream);
        return content;
    }