List of utility methods to do Text File Read All
String | readAll(File file) read All try (InputStream in = new FileInputStream(file)) { byte[] bs = new byte[(int) file.length()]; int p = 0, len; while ((len = in.read(bs, p, bs.length - p)) >= 0) p += len; if (p != bs.length) throw new RuntimeException(); return new String(bs); ... |
String | readAll(File file) read All StringBuilder builder = new StringBuilder(); FileInputStream intput = new FileInputStream(file); Scanner scanner = new Scanner(intput, "UTF-8"); while (scanner.hasNextLine()) { builder.append(scanner.nextLine()); builder.append("\n"); scanner.close(); ... |
byte[] | readAll(final String path) Reads all file. if (Strings.isNullOrEmpty(path)) { throw new IOException(new IllegalArgumentException("The reading file is not defined.")); return readRange(path, 0, new File(path).length()); |
String | readAllFile(File file) read All File try { FileInputStream i = new FileInputStream(file); byte[] r = new byte[(int) file.length()]; i.read(r); return new String(r); } catch (Exception e) { return null; |
byte[] | readAllFile(String fileName) read All File InputStream is = new FileInputStream(fileName); try { int n = is.available(); byte[] data = new byte[n]; is.read(data); return data; } finally { is.close(); ... |
String | readAllText(final String filename) read All Text FileInputStream fis = null; try { File file = new File(filename.toString()); fis = new FileInputStream(file); int size = fis.available(); byte[] contents = new byte[size]; fis.read(contents); return new String(contents); ... |