Files IO
REading
For small files use
byte[] bytes = Files.readAllBytes(Path.of(fileName));
String text = Files.readString(Path.of(fileName));
List<String> lines = Files.readAllLines(Path.of(fileName));
Stream<String> lines = Files.lines(Path.of(fileName));LArge files
try (FileInputStream is = new FileInputStream(fileName)) {
int b;
while ((b = is.read()) != -1) { // -1 is EoF
System.out.println("Byte: " + b);
}
}JAva 8
Streams and Buffers
Creating files
Paths
Locking
PDF
CSV
Links
Last updated