SlideShare a Scribd company logo
1 of 18
Featuring JDK 7 NIO 2 @edgedalmacio about.me/edgedalmacio haybol.ph
THANK YOU
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.
java.nio.file.Path
Creating a Path import java.nio.file.Paths; Path p1 = Paths.get("/tmp/foo");  Path p2 = Paths.get(args[0]);  Path p3 = Paths.get( URI.create("file:///Users/joe/FileTest.java"));
Checking File Accessibility import java.nio.file.Files; Path file = ...;  booleanisRegularExecutableFile 	= Files.isRegularFile(file)  	& Files.isReadable(file)  	& Files.isExecutable(file);
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  }
Deleting a File or Directory try { Files.delete(path); }  catch  (NoSuchFileException) … catch (DirectoryNotEmptyException) … catch  (IOException) …
Copying a File or Directory import static java.nio.file.StandardCopyOption.*;  …  Files.copy(source, target, REPLACE_EXISTING, COPY_ATTRIBUTES, NOFOLLOW_LINKS);
Managing Metadata java.nio.file.Files size isDirectory isRegularFile isSymbolicLink isHidden get/setLastModifiedTime get/setOwner get/setPosixFilePermissions get/setAttribute
Reading, Writing and Creating Files
Reading a File by Using Buffered Stream I/O BufferedReaderreader = Files.newBufferedReader 		(file, charset) reader.readLine();
Methods for Unbuffered Streams and Interoperable with java.io APIs InputStreamin = Files.newInputStream(file);  BufferedReaderreader =  new BufferedReader( 	new InputStreamReader(in)); reader.readLine();
Interoperability With Legacy Code java.io.Filefile =  	new File(pathname); java.nio.file.Path path =  file.toPath();
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.
About Orange & Bronze Software Labs ,[object Object]
Consulting, outsourcing, and offshore product development services using Open Source technologies, with a specialization in the Spring and Grails frameworks
Enterprise solutions with Google enterprise products and business intelligence solutions with the Pentaho BI Suite

More Related Content

Viewers also liked

Introducing the Java NIO.2
Introducing the Java NIO.2Introducing the Java NIO.2
Introducing the Java NIO.2
Fadel Adoe
 
Introduction of netty
Introduction of nettyIntroduction of netty
Introduction of netty
Bing Luo
 

Viewers also liked (19)

Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2
 
Nio2
Nio2Nio2
Nio2
 
Technology trends and the skills you should learn
Technology trends and the skills you should learnTechnology trends and the skills you should learn
Technology trends and the skills you should learn
 
Agile Executive Forum: Welcoming Remarks
Agile Executive  Forum: Welcoming RemarksAgile Executive  Forum: Welcoming Remarks
Agile Executive Forum: Welcoming Remarks
 
Why Most IT Projects Fail
Why Most IT Projects FailWhy Most IT Projects Fail
Why Most IT Projects Fail
 
Are you Agile enough?
Are you Agile enough?Are you Agile enough?
Are you Agile enough?
 
Google Apps for Business with Archiving & Discovery
Google Apps for Business with Archiving & Discovery Google Apps for Business with Archiving & Discovery
Google Apps for Business with Archiving & Discovery
 
Agile Software Development - Making Programming Fun Again
Agile Software Development - Making Programming Fun AgainAgile Software Development - Making Programming Fun Again
Agile Software Development - Making Programming Fun Again
 
What is agile
What is agileWhat is agile
What is agile
 
Agile Executive Forum: Agile Development Practices at Sabre
Agile Executive  Forum: Agile Development Practices at SabreAgile Executive  Forum: Agile Development Practices at Sabre
Agile Executive Forum: Agile Development Practices at Sabre
 
Agile Executive Forum: Agile and Outsourcing
Agile Executive Forum: Agile and OutsourcingAgile Executive Forum: Agile and Outsourcing
Agile Executive Forum: Agile and Outsourcing
 
Lesser Known Opportunities in Technology
Lesser Known Opportunities in TechnologyLesser Known Opportunities in Technology
Lesser Known Opportunities in Technology
 
Agile Executive Forum: O&B Adoption Story
Agile Executive Forum: O&B Adoption StoryAgile Executive Forum: O&B Adoption Story
Agile Executive Forum: O&B Adoption Story
 
Introducing the Java NIO.2
Introducing the Java NIO.2Introducing the Java NIO.2
Introducing the Java NIO.2
 
Java NIO.2
Java NIO.2Java NIO.2
Java NIO.2
 
NIO and NIO2
NIO and NIO2NIO and NIO2
NIO and NIO2
 
Introduction of netty
Introduction of nettyIntroduction of netty
Introduction of netty
 
Sip Fundamentals and Prospects Tutorial - VoiceCon Orlando 2010
Sip Fundamentals and Prospects Tutorial - VoiceCon Orlando 2010Sip Fundamentals and Prospects Tutorial - VoiceCon Orlando 2010
Sip Fundamentals and Prospects Tutorial - VoiceCon Orlando 2010
 

Similar to Featuring JDK 7 Nio 2

file-transfer-using-tcp.pdf
file-transfer-using-tcp.pdffile-transfer-using-tcp.pdf
file-transfer-using-tcp.pdf
Jayaprasanna4
 
7.Canon & Dt
7.Canon & Dt7.Canon & Dt
7.Canon & Dt
phanleson
 
Dan Crowley - Jack Of All Formats
Dan Crowley - Jack Of All FormatsDan Crowley - Jack Of All Formats
Dan Crowley - Jack Of All Formats
Source Conference
 

Similar to Featuring JDK 7 Nio 2 (20)

Know how to redirect input and output- and know how to append to an ex.docx
Know how to redirect input and output- and know how to append to an ex.docxKnow how to redirect input and output- and know how to append to an ex.docx
Know how to redirect input and output- and know how to append to an ex.docx
 
FileHandling.docx
FileHandling.docxFileHandling.docx
FileHandling.docx
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
 
JAVA
JAVAJAVA
JAVA
 
file-transfer-using-tcp.pdf
file-transfer-using-tcp.pdffile-transfer-using-tcp.pdf
file-transfer-using-tcp.pdf
 
Secure Code Warrior - Local file inclusion
Secure Code Warrior - Local file inclusionSecure Code Warrior - Local file inclusion
Secure Code Warrior - Local file inclusion
 
WhatsNewNIO2.pdf
WhatsNewNIO2.pdfWhatsNewNIO2.pdf
WhatsNewNIO2.pdf
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the future
 
Clean Sweep FileSystem - Java NIO 2
Clean Sweep FileSystem - Java NIO 2Clean Sweep FileSystem - Java NIO 2
Clean Sweep FileSystem - Java NIO 2
 
Chapter 5 Class File
Chapter 5 Class FileChapter 5 Class File
Chapter 5 Class File
 
7.Canon & Dt
7.Canon & Dt7.Canon & Dt
7.Canon & Dt
 
what are python basics.pptx.Join Python training in Chandigarh
what are python basics.pptx.Join Python training in Chandigarhwhat are python basics.pptx.Join Python training in Chandigarh
what are python basics.pptx.Join Python training in Chandigarh
 
Dan Crowley - Jack Of All Formats
Dan Crowley - Jack Of All FormatsDan Crowley - Jack Of All Formats
Dan Crowley - Jack Of All Formats
 
java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and files
 
Java Week4(A) Notepad
Java Week4(A)   NotepadJava Week4(A)   Notepad
Java Week4(A) Notepad
 
Jstreams
JstreamsJstreams
Jstreams
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 
Saveface - Save your Facebook content as RDF data
Saveface - Save your Facebook content as RDF dataSaveface - Save your Facebook content as RDF data
Saveface - Save your Facebook content as RDF data
 
DIWE - File handling with PHP
DIWE - File handling with PHPDIWE - File handling with PHP
DIWE - File handling with PHP
 
Python, WebRTC and You
Python, WebRTC and YouPython, WebRTC and You
Python, WebRTC and You
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Featuring JDK 7 Nio 2

  • 1. Featuring JDK 7 NIO 2 @edgedalmacio about.me/edgedalmacio haybol.ph
  • 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.
  • 5. Creating a Path import java.nio.file.Paths; Path p1 = Paths.get("/tmp/foo"); Path p2 = Paths.get(args[0]); Path p3 = Paths.get( URI.create("file:///Users/joe/FileTest.java"));
  • 6. Checking File Accessibility import java.nio.file.Files; Path file = ...; booleanisRegularExecutableFile = Files.isRegularFile(file) & Files.isReadable(file) & Files.isExecutable(file);
  • 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);
  • 10. Managing Metadata java.nio.file.Files size isDirectory isRegularFile isSymbolicLink isHidden get/setLastModifiedTime get/setOwner get/setPosixFilePermissions get/setAttribute
  • 11. Reading, Writing and Creating Files
  • 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
  • 19. Offers Java, Agile and Android training courseswww.orangeandbronze.com
  • 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/