Here you can find the source of readAllStreamsFromClasspathBaseResource(Class> resourceBase, String[] dataLocations)
public static List<String> readAllStreamsFromClasspathBaseResource(Class<?> resourceBase, String[] dataLocations) 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; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> readAllStreamsFromClasspathBaseResource(Class<?> resourceBase, String[] dataLocations) throws IOException { final List<String> scriptContent = new ArrayList<String>(); for (int i = 0; i < dataLocations.length; i++) { String content = readAllStreamFromClasspathBaseResource(resourceBase, dataLocations[i]); if (content != null) { scriptContent.add(content); }//from ww w . j av a 2 s. co m } return scriptContent; } public static String readAllStreamFromClasspathBaseResource(Class<?> resourceBase, String dataLocation) throws IOException { if (isFileAvailableOnClasspath(resourceBase, dataLocation)) { return readFullStream(resourceBase.getResourceAsStream(dataLocation)); } else { 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(); } }