List of utility methods to do Text File Load
String | loadText(File f) load Text return loadReader(new InputStreamReader(new FileInputStream(f))); |
String | loadText(File file) This method wraps all the horrid Java 6 IO APIs for extracting a String from a text file. try { BufferedReader reader = new BufferedReader(new FileReader(file)); StringWriter writer = new StringWriter(); try { String line = reader.readLine(); while (null != line) { writer.append(line).append("\n"); line = reader.readLine(); ... |
String | loadText(File file) Load a text file as a single string. StringBuffer sb = new StringBuffer(); BufferedReader br = read(file); try { String line = br.readLine(); while (line != null) { sb.append(line); line = br.readLine(); if (line != null) { ... |
String | loadText(File file) Loads text into a string from a file String ls = System.getProperty("line.separator"); StringBuffer text = new StringBuffer(); BufferedReader in = new BufferedReader(new FileReader(file)); String line = null; boolean hasLine = false; while ((line = in.readLine()) != null) { if (hasLine) { text.append(ls); ... |
StringBuffer | loadText(File file, int bufsize) Takes the contents of a text file and returns it as a StringBuffer .
FileReader rdr = new FileReader(file); try { return load(rdr, bufsize); finally { shutdown(rdr); |
String | loadText(java.io.File f) Loads a text file 'f' and returns its content as a String. java.io.StringWriter ans = new java.io.StringWriter(); try { copyRW(new java.io.FileReader(f), ans).close(); } catch (java.io.IOException e) { return ans.toString(); |
String | loadText(String fname) load Text String s = ""; try { BufferedReader r = new BufferedReader( new InputStreamReader(new FileInputStream(fname), "windows-1251")); while (r.ready()) s = s + r.readLine() + "\n"; r.close(); } catch (Exception ex) { ... |
String | loadText(String path) load Text String result = ""; try { BufferedReader reader = new BufferedReader(new FileReader(path)); String buffer; while ((buffer = reader.readLine()) != null) { result += buffer + "\n"; } catch (IOException e) { ... |
String | loadText(String path) Reads a whole text file into a String. BufferedReader reader = new BufferedReader(new FileReader(path)); String line; StringBuilder text = new StringBuilder(); while ((line = reader.readLine()) != null) { text.append(line); text.append("\n"); return text.toString(); ... |
String | loadTextFile(File file) Fetch the entire contents of a text file, and return it in a String. StringBuffer contents = new StringBuffer(); BufferedReader input = new BufferedReader(new FileReader(file)); try { String line = null; while ((line = input.readLine()) != null) { contents.append(line); contents.append(System.getProperty("line.separator")); } finally { input.close(); return contents.toString(); |