List of utility methods to do BufferedReader Read All
List | readAllLines(InputStream inputStream) read All Lines BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); List<String> data = new ArrayList<>(); for (String line; (line = br.readLine()) != null;) { data.add(line); return data; |
List | readAllLines(InputStream is) read All Lines List<String> ls = new ArrayList<String>(); BufferedReader buffer = new BufferedReader(new InputStreamReader(is)); String line; while ((line = buffer.readLine()) != null) { ls.add(line); return ls; |
List | readAllLines(String filepath) read All Lines List<String> fileContent = new ArrayList<String>(); File file = new File(filepath); BufferedReader input = new BufferedReader(new FileReader(file)); try { String line = null; while ((line = input.readLine()) != null) { fileContent.add(line); } finally { if (input != null) input.close(); return fileContent; |
String | readAllStreamFromClasspathBaseResource(Class> resourceBase, String dataLocation) read All Stream From Classpath Base Resource if (isFileAvailableOnClasspath(resourceBase, dataLocation)) { return readFullStream(resourceBase.getResourceAsStream(dataLocation)); } else { return null; |
List | readAllStreamsFromClasspathBaseResource(Class> resourceBase, String[] dataLocations) read All Streams From Classpath Base Resource 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); return scriptContent; ... |
String | readAllText(File file) read All Text StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new FileReader(file)); String line; while ((line = br.readLine()) != null) sb.append(line + "\n"); br.close(); return sb.toString(); |
String | readAllText(File file) Read the given file and return its contents as string if (file == null || !file.exists()) return null; BufferedReader reader; StringBuilder builder = new StringBuilder(); try { reader = new BufferedReader(new FileReader(file)); String line; while ((line = reader.readLine()) != null) ... |
String | readAllText(final InputStream inputStream) read All Text try (final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { final StringBuffer buff = new StringBuffer(); String line = null; while ((line = reader.readLine()) != null) { buff.append(line + System.lineSeparator()); return buff.toString(); } catch (NullPointerException e) { ... |
String | readAllText(InputStream stream) Reads all text from the stream using the default charset. BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); StringBuilder result = new StringBuilder(); while (true) { String s = reader.readLine(); if (s == null) { return result.toString(); result.append(s); ... |
String | readAllText(String filePath) read All Text BufferedReader reader = new BufferedReader(new FileReader(filePath)); StringBuilder result = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) result.append(line).append("\r\n"); reader.close(); return result.toString(); |