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

su.boleyn.oj.core.FileUtils Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package su.boleyn.oj.core;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class FileUtils extends Config {
	private static final String DATA_PATH = getOrFail("DATA");

	public static String read(String path) throws IOException {
		BufferedReader reader = new BufferedReader(
				new InputStreamReader(new FileInputStream(DATA_PATH + path), "utf-8"));
		StringBuffer data = new StringBuffer();
		char[] buffer = new char[1024];
		int length;
		while ((length = reader.read(buffer)) != -1) {
			data.append(String.valueOf(buffer, 0, length));
		}
		reader.close();
		return data.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy