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 {
    /**
     * Performs copy of one stream into another.
     * @param is - input stream
     * @param os - output stream
     * @throws IOException
     */
    public static void copyStream(InputStream is, OutputStream os) throws IOException {
        byte[] buffer = new byte[1024];
        int count = 0;

        while ((count = is.read(buffer)) != -1) {
            os.write(buffer, 0, count);
        }

        os.flush();
    }
}