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

com.jtransc.text.JTranscReaderTools Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.

There is a newer version: 0.6.8
Show newest version
package com.jtransc.text;

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

public class JTranscReaderTools {
	static public String readAllOrNull(Reader reader) {
		try {
			return readAll(reader);
		} catch (IOException e) {
			return null;
		}
	}

	static public String readAll(Reader reader) throws IOException {
		char[] arr = new char[8 * 1024];
		StringBuilder buffer = new StringBuilder();
		int numCharsRead;
		while ((numCharsRead = reader.read(arr, 0, arr.length)) != -1) {
			buffer.append(arr, 0, numCharsRead);
		}
		reader.close();
		return buffer.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy