Here you can find the source of readAllStreamFromClasspathBaseResource(Class> resourceBase, String dataLocation)
public static String readAllStreamFromClasspathBaseResource(Class<?> resourceBase, String dataLocation) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readAllStreamFromClasspathBaseResource(Class<?> resourceBase, String dataLocation) throws IOException { if (isFileAvailableOnClasspath(resourceBase, dataLocation)) { return readFullStream(resourceBase.getResourceAsStream(dataLocation)); } else {/* w ww .j a v a 2 s. co m*/ return null; } } public static boolean isFileAvailableOnClasspath(Class<?> resourceBase, String dataLocation) { return resourceBase.getResourceAsStream(dataLocation) != null; } public static String readFullStream(InputStream data) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(data, "UTF-8")); StringBuilder readData = new StringBuilder(); String readLine; while ((readLine = bufferedReader.readLine()) != null) { readData.append(readLine); } return readData.toString(); } }