[1662326 views]

[]

Odi's astoundingly incomplete notes

New entries | Code

Java and its use of filesystem syscalls

File f = new File("build.xml");
// openat(AT_FDCWD, "build.xml", O_RDONLY) = 96
// fstat(96
InputStream io = new FileInputStream(f);
// read(96
io.read();
// read(96
io.read();
// close(96)
io.close();


Path p = f.toPath();
// openat(AT_FDCWD, "build.xml", O_RDONLY) = 96
io = Files.newInputStream(p);
// read(96
io.read();
// read(96
io.read();
// close(96)
io.close();
The NIO way of creating an input stream from a file actually saves an fstat syscall.
posted on 2019-10-01 13:36 UTC in Code | 0 comments | permalink