List of utility methods to do Path File Read nio
void | readAndConsume(String filePath, Consumer read And Consume Stream<String> lines = null; lines = Files.lines(Paths.get(filePath)); lines.forEach(consumer); |
String | readAsString(Path path) read As String InputStream in = null; try { in = Files.newInputStream(path); return new String(read(in)); } finally { if (in != null) { in.close(); |
String | readAsString(String path) read As String try (BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8))) { String line = null; StringBuilder sb = new StringBuilder(4096); while ((line = reader.readLine()) != null) { sb.append(line).append('\n'); return sb.toString(); ... |
String | reader(String path) reader InputStream in = fileIn(path); String val = getString(in).toString(); close(in); return val; |
String[] | readers(String path) readers FileReader fileReader = new FileReader(path); BufferedReader fr = new BufferedReader(fileReader); String line = null; List<String> list = new ArrayList<>(); while (null != (line = fr.readLine())) { list.add(line); close(fileReader); ... |
List | readFile(Path directory, String... parts) Reads the file under the directory/parts[0]/parts[1]/.../parts[n] using ISO_8859_1.
return readFile(resolve(directory, parts));
|
String | readFile(Path file) read File StringBuilder strBuilder = new StringBuilder(); for (String line : Files.readAllLines(file, StandardCharsets.UTF_8)) { strBuilder.append(line).append('\n'); return strBuilder.toString(); |
String | readFile(Path path) read File String pathToFile = path.toString(), line = ""; try (BufferedReader br = new BufferedReader(new FileReader(pathToFile))) { while (true) { try { line = line.concat(br.readLine()); } catch (IOException ex) { ex.printStackTrace(System.err); } catch (NullPointerException ex) { ... |
byte[] | readFile(Path path) Fully reads a file into a byte array. try (final InputStream in = Files.newInputStream(path)) { return readStream(in); |
String | readFile(String path) Reads the contents of a file into a string. return read(new File(path)); |