List of utility methods to do BufferedReader Read
String | readFile(String path) Reads a file and returns the content as a big String. StringBuilder buffer = new StringBuilder(); try { BufferedReader reader = new BufferedReader(new FileReader(new File(path))); String line; while ((line = reader.readLine()) != null) buffer.append(line).append('\n'); } catch (FileNotFoundException ex) { System.err.println("File " + path + " was not found..."); ... |
List | readFile(String pathname) Reads the file at the specified pathname and returns it as a List of Strings, one per line of the file. List<String> lines = new ArrayList<>(); BufferedReader reader = new BufferedReader(new FileReader(pathname)); while (reader.ready()) { lines.add(reader.readLine()); reader.close(); return lines; |
String | readFile(String sFileName_) Reads a File and returns the content in a String. StringBuffer sFileContent = new StringBuffer(100000); try { FileReader frIni = new FileReader(sFileName_); if (frIni != null) { BufferedReader brIni = new BufferedReader(frIni); if (brIni != null) { while (brIni.ready()) { String sLine = brIni.readLine(); ... |
String | readFile(String uri) Read file. File file = new File(uri); FileReader fr = new FileReader(file.getAbsoluteFile()); BufferedReader br = new BufferedReader(fr); String value = br.readLine(); br.close(); return value; |
String | readFile(String xmlFile) read File StringBuffer fileContent = new StringBuffer(); try { FileReader reader = new FileReader(new File(xmlFile)); BufferedReader buffer = new BufferedReader(reader); String line = ""; int i = 0; while ((line = buffer.readLine()) != null) { if (i != 0) ... |
HashMap | readFileAsHash(File file) read File As Hash StringBuffer stringBuffer = new StringBuffer(); HashMap<String, String> pairs = new HashMap<String, String>(); try { BufferedReader in = new BufferedReader(new FileReader(file)); try { int size = 0; char[] buff = new char[512]; while ((size = in.read(buff)) >= 0) { ... |
List | readFileAsLines(File fileLocation) read File As Lines List<String> lines = new ArrayList<String>(); FileReader fr = null; BufferedReader br = null; if (fileLocation != null) { try { fr = new FileReader(fileLocation); br = new BufferedReader(fr); String line = null; ... |
List | readFileAsLines(String aFile) read File As Lines BufferedReader input = new BufferedReader(new FileReader(aFile)); List<String> lines = new Vector<String>(); try { String line = null; while ((line = input.readLine()) != null) { lines.add(line); } finally { ... |
List | readFileAsList(final String filename) read File As List final File f = new File(filename); if (f.exists()) { return readFileAsList(f); return null; |
List | readFileAsList(String filename, String splitter) read File As List List<String> list = new ArrayList<String>(); File file = new File(filename); FileReader freader = new FileReader(file); StringBuilder builder = new StringBuilder(); try (BufferedReader breader = new BufferedReader(freader)) { String line = breader.readLine(); while (null != line) { builder.append(line); ... |