Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.io.Reader;

public class Main {
    /**
     * Slurps a Reader into a String.
     * @param in
     * @throws IOException
     */
    public static String readerToString(final Reader in) throws IOException {
        StringBuffer out = new StringBuffer();
        char[] b = new char[4096];
        for (int n; (n = in.read(b)) != -1;) {
            out.append(new String(b, 0, n));
        }
        return out.toString();
    }
}