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 {
    private static final int BUFFER_SIZE = 1024;

    /**
     * <p>Copies the data from the {@link InputStream} into a {@link OutputStream}</p>
     *
     * @param input  data source stream.
     * @param output target stream.
     *
     * @throws IOException if error happened.
     */
    public static void copyStream(InputStream input, OutputStream output) throws IOException {
        byte[] buffer = new byte[BUFFER_SIZE];
        int bytesRead;
        while ((bytesRead = input.read(buffer)) != -1) {
            output.write(buffer, 0, bytesRead);
        }
    }
}