From http://java.net/jira/browse/MACOSX_PORT-133 -- java.nio.file.Files .readAttributes throws NPE on MacOS Simple test case: import java.nio.file.attribute.DosFileAttributes; import java.nio.ByteBuffer; import java.nio.channels.SeekableByteChannel; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import static java.nio.file.StandardOpenOption.*; public class Test { public static void main(String argv[]) { Path path = Paths.get("temp.txt"); String data = "Hello world!"; SeekableByteChannel sbc = null; try { ByteBuffer bb = ByteBuffer.wrap(data.getBytes()); sbc = Files.newByteChannel(path, CREATE, WRITE); sbc.write(bb); DosFileAttributes dfa = null; dfa = Files.readAttributes(path, DosFileAttributes.class); } catch (Exception e) { e.printStackTrace(); } } } Test output: Exception in thread "main" java.lang.NullPointerException at sun.nio.fs.BsdFileSystemProvider.readAttributes(BsdFileSystemProvider.java:78) at java.nio.file.Files.readAttributes(Files.java:1669) at TestCopy01.test01(TestCopy01.java:85) at TestCopy01.main(TestCopy01.java:37)
|