All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jakewharton.Streams Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.jakewharton;

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

/** From libcore.io.Streams */
class Streams {
    static String readFully(Reader reader) throws IOException {
        try {
            StringWriter writer = new StringWriter();
            char[] buffer = new char[1024];
            int count;
            while ((count = reader.read(buffer)) != -1) {
                writer.write(buffer, 0, count);
            }
            return writer.toString();
        } finally {
            reader.close();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy