Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright 2000-2011 Enonic AS
 * http://www.enonic.com/license
 */

import java.io.IOException;
import java.io.Reader;

import java.io.Writer;

public class Main {
    /**
     * Copy buffer size.
     */
    private final static int COPY_BUFFER_SIZE = 4096;

    /**
     * Copy a reader to writer.
     */
    private static void copy(Reader in, Writer out) throws IOException {
        try {
            int bytesRead;
            char[] buffer = new char[COPY_BUFFER_SIZE];

            while ((bytesRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, bytesRead);
            }

            out.flush();
        } finally {
            in.close();
            out.close();
        }
    }
}