Java BufferedInputStream to Byte Array nextBytes(BufferedInputStream in)

Here you can find the source of nextBytes(BufferedInputStream in)

Description

next Bytes

License

Apache License

Declaration

public static byte[] nextBytes(BufferedInputStream in) throws IOException 

Method Source Code


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

import java.io.BufferedInputStream;

import java.io.IOException;

public class Main {

    public static byte[] nextBytes(BufferedInputStream in) throws IOException {
        byte[] bytes = new byte[100];
        int num;//ww  w .  ja v  a 2 s.com
        num = in.read(bytes);
        if (num == -1)
            return null;
        if (num < 100) {
            byte[] result = new byte[num];
            for (int index = 0; index < num; index++)
                result[index] = bytes[index];
        }
        return bytes;
    }
}