Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    static byte[] streamToBytes(InputStream paramInputStream) throws IOException {
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
        if (paramInputStream != null) {
            byte[] arrayOfByte = new byte[4096];
            while (true) {
                int i = paramInputStream.read(arrayOfByte);
                if (i == -1)
                    break;
                localByteArrayOutputStream.write(arrayOfByte, 0, i);
            }
        }
        return localByteArrayOutputStream.toByteArray();
    }
}