Java InputStream to Byte Array inputStreamToByte(InputStream is)

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

Description

input Stream To Byte

License

Open Source License

Declaration

public static byte[] inputStreamToByte(InputStream is)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;

import java.io.IOException;
import java.io.InputStream;

public class Main {

    public static byte[] inputStreamToByte(InputStream is)
            throws IOException {
        ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
        int ch;/*  ww w .j a  v a  2 s . co  m*/
        while ((ch = is.read()) != -1) {
            bytestream.write(ch);
        }
        byte data[] = bytestream.toByteArray();
        bytestream.close();
        return data;
    }
}

Related

  1. inputStream2ByteArray(InputStream is)
  2. inputStreamAsBytes(InputStream stream)
  3. inputStreamToArray(InputStream is)
  4. InputStreamTOByte(InputStream in)
  5. inputStreamToByte(InputStream in)
  6. inputStreamToByteArray(final InputStream is, final int bufferSize)
  7. inputStreamToByteArray(InputStream in)
  8. inputStreamToByteArray(InputStream in)
  9. inputStreamToByteArray(InputStream input, int size)