Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DirectoryIteratorException - List directory NIO2

 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In NIO2 oracle tutorial it says: http://docs.oracle.com/javase/tutorial/essential/io/dirs.html#listdir
Note that if there is an exception during directory iteration then DirectoryIteratorException is thrown with the IOException as the cause. Iterator methods cannot throw exception exceptions.


Can someone elaborate on that?

Thanks
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DirectoryIteratorException is an unchecked exception. what the docs says is that the iterator method cannot throw exception exceptions, meaning they cannot throw checked exceptions. also the cause of the DirectorIteratorException is IOException which is a checked exception , but this exception is wrapped and thrown as DirectoryIteratorException
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gurpeet singh wrote:DirectoryIteratorException is an unchecked exception. what the docs says is that the iterator method cannot throw exception exceptions, meaning they cannot throw checked exceptions. also the cause of the DirectorIteratorException is IOException which is a checked exception , but this exception is wrapped and thrown as DirectoryIteratorException


Hmm i think it is in new OCJP 7.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic