Java Dump Stream dumpInputStreamIntoString(InputStream f, String encoding)

Here you can find the source of dumpInputStreamIntoString(InputStream f, String encoding)

Description

dump Input Stream Into String

License

Apache License

Declaration

public static String dumpInputStreamIntoString(InputStream f, String encoding) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedInputStream;

import java.io.ByteArrayOutputStream;

import java.io.InputStream;

public class Main {
    public static String dumpInputStreamIntoString(InputStream f, String encoding) throws Exception {
        ByteArrayOutputStream byteStream = null;
        BufferedInputStream fileStream = null;
        byteStream = new ByteArrayOutputStream();
        fileStream = new BufferedInputStream((f));
        int data = -1;
        while ((data = fileStream.read()) != -1) {
            byteStream.write(data);/*  w w  w. ja  va 2 s.  c o m*/
        }
        byte[] raw = byteStream.toByteArray();
        return new String(raw, encoding);

    }
}

Related

  1. dumpInputOutputStream(InputStream is, OutputStream os)
  2. dumpInputStream(InputStream instream)
  3. dumpInputStream(InputStream is, PrintStream p)
  4. dumpInputStream(InputStream stream)
  5. dumpInputStreamAsString(InputStream is)
  6. dumpMap(PrintStream out, Map Values)
  7. dumpStream(InputStream in, PrintStream dump, boolean closeIn)
  8. dumpStream(InputStream in, String file)
  9. dumpStreamAndReOffer(InputStream is)