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 {
    public static byte[] toByte(InputStream input) throws IOException {
        byte[] buf = new byte[1024];
        int len = -1;
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        while ((len = input.read(buf)) != -1) {
            output.write(buf, 0, len);
        }
        byte[] data = output.toByteArray();
        output.close();
        input.close();
        return data;
    }
}