Join David Gassner for an in-depth discussion in this video Walking the directory tree, part of Advanced Java Programming.
Java 7 new files API gives you the ability to easily walk a directory tree, starting…off at a parent directory and then examining all of its subfolders and subfolders of subfolders and so on,…and all of the files within those folders.…I'll demonstrate how to do this with the project FileTree, which has a set of files in directories and subdirectories.…There's a parent directory called files and two subdirectories name dir1 and dir2 and…files within each of those.…
Within my main method, I've defined an instance of path pointing to the files directory.…To implement this functionality, you create your own custom class that extends a class…called SimpleFileVisitor.…I'll go to my FileTree package and create a New > Class, and I'll name it MyFileVisitor.…I'll set the Superclass by clicking Browse, and I'll type in SimpleFile, and I'll choose…SimpleFileVisitor from java.nio.file.…
I'll click Finish, and that creates the basic class.…Now I'll make one immediate change.…The SimpleFileVisitor class has a generic data type, I'll change the generic from T to the Path class.…
- Installing Java on Windows and Mac OS X
- Installing Eclipse
- Using new features such as simplified generics
- Working with advanced class structures (member, local inner, etc.)
- Using the Reflection API
- Navigating inheritance trees
- Managing unordered and ordered sets
- Peeking and polling with queues
- Testing and error handling
- Managing files and directories
- Working with I/O streams
- Next steps with Java
Skill Level Advanced
1. Getting Started
2. Java 7 New Features
3. Using Advanced Class Structures
4. Using the Reflection API
5. More of the Collections Framework
6. Testing and Advanced Exception Handling
Using the finally keyword5m 40s
7. Managing Files and Directories in Java 7
8. Working with I/O Streams
9. Working with Multi-threading
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.