Java ByteArrayOutputStream Write readAllAndClose(InputStream is)

Here you can find the source of readAllAndClose(InputStream is)

Description

read All And Close

License

Open Source License

Declaration

public static String readAllAndClose(InputStream is) throws Exception 

Method Source Code


//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;

public class Main {
    public static String readAllAndClose(InputStream is) throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {/*  ww w.jav a 2s  .co m*/
            int read;
            while ((read = is.read()) != -1) {
                out.write(read);
            }
        } finally {
            try {
                is.close();
            } catch (Exception e) {
            }
        }
        return out.toString();
    }
}

Related

  1. readAll(InputStream in)
  2. readAll(InputStream inputStream)
  3. readAll(InputStream is)
  4. readAll(InputStream s)
  5. readAll(InputStream stream)
  6. readAllAndKeepOpen(InputStream bytes, int bufferSize)
  7. readAllBinary(InputStream stream)
  8. readAllFrom(InputStream in, boolean chunked)
  9. readAllFromFile(File f)