Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static final int BUFFER_SIZE = 8192;

    /**
     * Copies inputStream to outputStream in a somewhat buffered way
     * @param in Input stream
     * @param out Output stream
     * @throws IOException if the operation fails
     */
    public static void copyStream(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[BUFFER_SIZE];
        int read;
        while ((read = in.read(buffer)) != -1) {
            out.write(buffer, 0, read);
        }
    }
}