List of utility methods to do File to String Read
String[] | getStringArrayFromFile(File inputFile) get String Array From File ArrayList list = new ArrayList(); BufferedReader br = new BufferedReader(new FileReader(inputFile)); while (true) { String line = br.readLine(); if (line == null) break; list.add(line); br.close(); return (String[]) list.toArray(new String[0]); |
String | getStringFromFile(File inputFile) get String From File Validate.notNull(inputFile); Validate.isTrue(inputFile.exists()); return IO.toString(new FileInputStream(inputFile)); |
String | fromFile(File f) from File InputStream is = new FileInputStream(f); byte[] bs = new byte[is.available()]; is.read(bs); is.close(); return new String(bs); |
String | readFile(String path) read File StringBuffer str = new StringBuffer(""); try { InputStreamReader ir = new InputStreamReader( new FileInputStream(path), "UTF8"); BufferedReader br = new BufferedReader(ir); String data = br.readLine(); while (data != null) { str.append(data); ... |
List | readFileOfList(String path) read File Of List List<String> list = new ArrayList<String>(); InputStreamReader ir = null; BufferedReader br = null; try { ir = new InputStreamReader(new FileInputStream(path), "UTF8"); br = new BufferedReader(ir); String data = br.readLine(); while (data != null) { ... |