Join David Gassner for an in-depth discussion in this video Watching a directory for file changes, part of Advanced Java Programming.
Java 7's new Files API has a tool that lets you easily create a watch service,…a service that watches the contents of a directory, and reports when any of the directory's contents…are created, deleted, or modified.…I'll show how to use this in this pretty much new project that has a Main class with an…empty Main method and an empty Files directory.…So, I'm going to be coding this entirely from scratch.…I'll start in the Main method.…Within the Main method, I'll create a Try/catch Block.…
I'll use the new TryWithResources syntax.…And within the parentheses of the Try keyword, I'll create an instance of the new WatchService class.…I'll name this service, and I'll instantiate it with the following code: FileSystems.getDefault,…that's a reference to the current file system .newWatchService.…So now, because I'm creating the service object inside the Try parentheses, when the Try/catch…is completed, it will be released completely, and you won't have to explicitly call close…methods or reset it to null.…
- 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.