public static void fsync ( final Path path ) throws IOException { if ( ! Files . isDirectory ( path ) && ! Files . isRegularFile ( path ) ) { throw new IllegalArgumentException ( "fsync is only supported for regular files and directories: " + path ) ; } try ( final FileChannel channel = FileChannel . open ( path , StandardOpenOption . READ ) ) { channel . force ( true ) ; } }
Fsync a single path . Please only call this on things that are Directories or NormalFiles .