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.Reader;

public class Main {
    /**
     * Load the characters contained in specified source.
     * 
     * @param in the character source
     * @return the contents of the character source
     * @exception IOException if there is an I/O problem
     */
    public static String loadChars(Reader in) throws IOException {
        StringBuilder buffer = new StringBuilder();
        char[] chars = new char[65536];
        int count;

        while ((count = in.read(chars, 0, chars.length)) != -1) {
            if (count > 0) {
                buffer.append(chars, 0, count);
            }
        }

        return buffer.toString();
    }
}