Edge Dalmacio, Co-Founder of Haybol.ph and Senior Software Engineer at Orange and Bronze, discusses JDK 7 Nio 2 at the PinoyJUG Java 7 Release Party.
www.orangeandbronze.com
3. java.io.File Many methods didn't throw exceptions when they failed. Rename method didn't work consistently across platforms. There was no real support for symbolic links. Limited support for metadata, such as file permissions, file owner, and other security attributes. Accessing file metadata was inefficient. Many of the File methods didn't scale. It was not possible to write reliable code that could recursively walk a file tree and respond appropriately if there were circular symbolic links.
7. Checking Whether Two Paths Locate the Same File Path p1 = ...; Path p2 = ...; if (Files.isSameFile(p1, p2)) { //Logic when the paths locate the same file }
8. Deleting a File or Directory try { Files.delete(path); } catch (NoSuchFileException) … catch (DirectoryNotEmptyException) … catch (IOException) …
9. Copying a File or Directory import static java.nio.file.StandardCopyOption.*; … Files.copy(source, target, REPLACE_EXISTING, COPY_ATTRIBUTES, NOFOLLOW_LINKS);
12. Reading a File by Using Buffered Stream I/O BufferedReaderreader = Files.newBufferedReader (file, charset) reader.readLine();
13. Methods for Unbuffered Streams and Interoperable with java.io APIs InputStreamin = Files.newInputStream(file); BufferedReaderreader = new BufferedReader( new InputStreamReader(in)); reader.readLine();
14. Interoperability With Legacy Code java.io.Filefile = new File(pathname); java.nio.file.Path path = file.toPath();
15. java.nio.file Path methods for manipulating a path. Files methods for file operations, such as moving, copy, deleting, and also methods for retrieving and setting file attributes. FileSystem methods for obtaining information about the file system.
16.
17. Consulting, outsourcing, and offshore product development services using Open Source technologies, with a specialization in the Spring and Grails frameworks
18. Enterprise solutions with Google enterprise products and business intelligence solutions with the Pentaho BI Suite
21. References File I/O (Featuring NIO.2) http://download.oracle.com/javase/tutorial/essential/io/fileio.html More New I/O APIs for the Java Platform http://openjdk.java.net/projects/nio/