Java Utililty Methods InputStream Copy

List of utility methods to do InputStream Copy

Description

The list of methods to do InputStream Copy are organized into topic(s).

Method

StringcopyStreamToString(InputStream inputStream, String encoding)
Copies data from the input stream and returns a String (UTF-8 if not specified)
encoding = (encoding == null) ? "UTF-8" : encoding;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
copyStream(inputStream, baos);
return baos.toString(encoding);
voidcopyStreamToWriter(InputStream in, Writer out, String encoding, boolean close)
Copies an InputStream to a Writer.
InputStreamReader reader = new InputStreamReader(in, encoding);
copyReaderToWriter(reader, out, close);
voidcopyStreamToWriter(InputStream inStream, Writer writer)
Copies contents of inStream to writer.
int data = -1;
while ((data = inStream.read()) != -1) {
    writer.write(data);