MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

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

public class MainClass {

    public static void main(String[] args) {

        try {
            copy(System.in, System.out);
        } catch (IOException ex) {
            System.err.println(ex);
        }
    }

    public static void copy(InputStream in, OutputStream out) throws IOException {

        BufferedInputStream bin = new BufferedInputStream(in);
        BufferedOutputStream bout = new BufferedOutputStream(out);

        while (true) {
            int datum = bin.read();
            if (datum == -1)
                break;
            bout.write(datum);
        }
        bout.flush();
    }
}