List of utility methods to do BufferedReader Read
StringBuilder | getFileContent(File f) get File Content StringBuilder tmp = new StringBuilder(); try { @SuppressWarnings("resource") BufferedReader br = new BufferedReader(new FileReader(f)); String line; while ((line = br.readLine()) != null) { tmp.append(line); tmp.append("\n"); ... |
String | readFileAsString(File file) read File As String StringBuilder sb = new StringBuilder(1000); BufferedReader reader = new BufferedReader(new FileReader(file)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { sb.append(buf, 0, numRead); reader.close(); ... |
void | readFileFolder(String filePath) read File Folder File file = new File(filePath); if (file.exists()) { if (file.isDirectory()) { System.out.println(file.getName()); File[] files = file.listFiles(); if (files != null && files.length > 0) { for (File f : files) { System.out.println(f.getName()); ... |
String | readStream(Reader r) Puts the whole stream into the string. StringBuffer buffer = new StringBuffer(); BufferedReader br = new BufferedReader(r); String line; while ((line = br.readLine()) != null) { buffer.append(line); return buffer.toString(); |
String | readStringFromBufferedReader(BufferedReader br) Reads all content from the given Reader and returns it as a single String StringBuffer sbr = new StringBuffer(); for (String ln = br.readLine(); ln != null; ln = br.readLine()) sbr.append(ln + "\n"); br.close(); return sbr.toString(); |
List | toList(String fileName) to List try { return toList(new FileReader(fileName)); } catch (IOException ioe) { return new ArrayList(); |