I want to get notified, when an USB-Drive is connected. So that java sais: "Drive H: created". Is there a way to do this with the WatchService? Watching the root-directory doesn't work. It just watches the root of the current drive: Paths.get("/").register
Java nio WatchService: Watch Windows drives list
1.3k Views Asked by USSEraser At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in WINDOWS
- Get Maximum Log Size
- Debugging Windows Services while starting
- Possible consequences of duplicate ProgId for different classes
- How to chain BCryptEncrypt and BCryptDecrypt calls using AES in GCM mode?
- mingw-64 conflicting declarations when cross-compiling
- I run an EXE program from a Windows Service but I can't see form C#?
- Why is PowerShell "not recognized" when installing Chocolatey?
- How to check if Windows device is phone or tablet/pc?
- How to add directories to Cygwin gcc default search path
- Can't install anything with pip2 on Windows 7 due to UnicodeDecodeError
- Active directory and linux nslcd binding without extending the AD schema
- How To Prevent Over Scrolling in Scroll Viewer Windows Phone 8.1
- Unicode error from pip install
- Where is the 'EnablePinning' property in the ribbon framework's recent items?
- How can I implement the same models and data across ASP.NET and Windows Apps
Related Questions in NIO
- Java NIO with sql database
- NoSuchFileException when creating a file using nio
- How to detect growth in file in java?
- Java nio cant read UNC
- Writing contents of ByteArrayOutputStream to a file using NIO FileChannel
- Socket vs SocketChannel.open().socket()
- Can Netty be used to boost Client / Server (in Jetty 9) application communication?
- Java WindowsSelectorImpl totalChannels
- One thread one ByteBuffer NIO
- Java nio FileSystem change root path
- Cancel a selection key but reuse it afterwards
- NoSuchFileException adding file to ZIP using Java NIO
- Mixing Java NIO with IO input streams read operation
- Why does the java DirectoryStream perform so slow?
- Difference between getCanonicalPath and toRealPath
Related Questions in WATCHSERVICE
- Why register method in Path class returns WatchKey? (Watch Service Api, Java SE 7)
- WatchService: passing parameter at registration
- Using WatchService in JAVA. Can I watch subdirectory at the same time?
- Monitor a http resource using Java NIO watch service
- StandardWatchEvents.ENTRY_MODIFY triggers with modifying a subfolder?
- Sequentially processing file in threadpool executor
- How to stop Java WatchService when is waiting for key?
- How to watch a folder and subfolders for changes
- Java I/O: Ensure a file is not locked by another process before any r/w operation
- WatchService performance with many directories
- Java WatchService watches not terminated
- How many newWatchService can I create in Java 7?
- Java nio WatchService: Watch Windows drives list
- WatchService and SwingWorker: how to do it correctly?
- Waiting for WatchService event to be done processing before accessing the event file
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You cannot do that with a
WatchService. Since you are only worried about Windows, you can simply pollFileSystem.getRootDirectoriesand detect changes.If you wanted this to work on other operating systems, you would have to poll
FileSystem.getFileStoresand figure out a way to get the root path for aFileStore./e1