All Questions
Tagged with watchservice java
208 questions
1
vote
1
answer
49
views
watchservice listener not working on tomcat
I want to start a watchservice application while starting tomcat.
I am doing this by using listener in web.xml.
As expected watch service run successfully, but after that tomcat doesn't start.
watch ...
0
votes
1
answer
147
views
CSV File Parsing Issue - csvParser.iterator().next()
Here is the Java code for reading and parsing a CSV file.
String filePath = dir.resolve(filename).toString();
try (FileReader fileReader = new FileReader(filePath);
CSVParser csvParser = new ...
4
votes
2
answers
403
views
Restart WatchService after exceptions
I'm using Java's WatchService API within my Spring Boot application to monitor a directory, and perform some actions on created files. This process is executed asynchronously: it starts automatically ...
0
votes
0
answers
73
views
java watchservice - running multiple job on cluster
I am using java watchservice to watch a specific folder when a specific file is written from another program.
I am running multiple jobs using this code and each watching each a specific folder that ...
0
votes
0
answers
23
views
Java WatchService and Firefox strange behavior
I use the sample from https://docs.oracle.com/javase/tutorial/essential/io/notification.html to watch user downloads folder in order to react when a specific file type is downloaded by user. The code ...
0
votes
1
answer
149
views
Java WatchService: Problem with AbsolutePath
I am not sure if this is a bug or if I am doing it wrong.
import java.io.*;
import java.nio.file.*;
import java.util.*;
void foo ()
{
String dir = "/tmp/mytest";
// ...
3
votes
1
answer
95
views
Which filesystems provide native support for Java's WatchService?
I want to use the Java WatchService in an IDE-like tool. It seems like a good match for the behaviors I need from it.
The trick is that my customers use the tool in all sorts of interesting ...
0
votes
1
answer
420
views
WatchService large number of directory (recursive)
I want to detect changes inside a directory, so I implement by using WatchService
public class DirWatcher implements Runnable {
private Path path;
private ExecutorService exe;
public ...
0
votes
0
answers
177
views
WatchService: Filter event notification based on filename pattern
currently i'm using an if statement to filter out watch event based on file name. if there a way for me to only getting notification from certain files based on filename pattern only?
Thanks
if (...
-2
votes
1
answer
498
views
monitor a Folder and extract all data in the file using java
am trying to monitor a folder/file for any changes and then extract all the data from the file and append it to the database using java.
i have tried the watch service api in java to monitor the file ...
0
votes
0
answers
187
views
WatchService watching files on distributed filesystem from multiple machines
I am trying to implement a WatchService that watches a filesystem for changes. Once files get created I want to create tasks for each new file and add that task to a distributed queue to let it get ...
0
votes
1
answer
140
views
WatchService Directory path incorrect after renaming Directory
The code registers any new directory created with the watch service to listen for all the events
and runs for a duration of 60 seconds[which can be changed with running time]
final class Test
{
...
2
votes
2
answers
239
views
Are memory-mapped files recognized by the Watch Service API?
I came up with this question because I want to recognize when a change occurred in the memory-mapped file. So I can handle appropriately on the second program.
Is this possible with the Watch Service?
...
1
vote
0
answers
199
views
Trigger when a new file is created android
I'm trying to create an app that notices when a new file is created in a certain directory of Internal Storage...
I've tried with WatchService with no success :
AccessDeniedException WatchService ...
0
votes
0
answers
353
views
AccessDeniedException WatchService android studio
i'm trying to build an app that notices when a file is created.
I've used WatchService but when i attempt to "register" there is the following error:
W/System.err: java.nio.file....
1
vote
1
answer
1k
views
How can i stop WatchService (java)
How can I stop the execution:
key = watchService.take()
my code:
//Watcher
public class DirectoryWatcherExample {
public static void main(String[] args) throws IOException, InterruptedException ...
1
vote
1
answer
732
views
WatchService: missing events
I've created a small Java app which monitors folders. It uses the observer pattern to notify different fileHandlers. The filehandler operation can take a few seconds to process the files. All works ...
2
votes
1
answer
1k
views
Kubernetes shared persistent volume between pods results in no file events
I have 2 pods that use the same pvc to mount a pv so that they can share files through the mounted directory. Pod A has a Java Application that watches for new files (using java.nio.file.WatchService) ...
2
votes
1
answer
3k
views
Java WatchService, perform action on event using threads
I can monitor a directory by registering cwith a WatchKey (there are tons of examples on the web) however this watcher catches every single event. E.g. On windows If am monitoring the d:/temp dir and ...
1
vote
1
answer
791
views
Waiting for WatchService event to be done processing before accessing the event file
I am watching a directory using java.nio.file.WatchService;
and every time a file is created I call processFile() passing it the File handle.
Here is the code for the watcher:
boolean poll = true;
...
1
vote
3
answers
545
views
FileNotFound exception even though file is in the place during watch service in java
I have a watch service running on a folder, when I am trying to modify and existing file using evenKind == Modify (basically pasting a same file without removing the current file) I am getting ...
0
votes
1
answer
1k
views
WatchService throwing ClosedWatchServiceException
I am using java.nio.file.WatchService to watch a directory in my Spring boot application. I am getting the following exception all the time and it does not seem like it is detecting any file changes ...
1
vote
1
answer
438
views
WatchService getting fired multiple times (MODIFY is fired and even before CREATE is finished) JAVA
I have a Service which checks for a ZIP file in a folder,
while(true) {
WatchKey wk = watchService.take();
for (WatchEvent<?> event : wk.pollEvents()) {
Kind<?> ...
0
votes
1
answer
357
views
@SpringBootTest decorator causes test to get stuck for WatchService
I have simple application which I want to use to watch over a directory, the way I have done it so far is by using WatchService class:
ApplicationClass:
@SpringBootApplication
public class ...
0
votes
2
answers
849
views
Java WatchService locks directory on Windows
It seems when you watch a directory using Java's WatchService and then try to rename its parent directory, the renaming will fail with an AccessDeniedException. The directory seems to be sort of ...
2
votes
1
answer
2k
views
Java NIO WatchService
I have Java project that we need to keep listening some path to detect if there is any new XML file and if true, we need to process it through few other rules.
The WatchService is doing very well to ...
0
votes
1
answer
2k
views
Use a file watcher to detect changes on a remote Linux server [closed]
I have a requirement of detecting addition of new files into a folder on a remote Linux server that follows SFTP for its connection.
Right now I am trying to detect the changes from local(windows OS ) ...
0
votes
2
answers
381
views
How can I use Java to read a key value in an ini file that points to a text file?
I currently have created a Java app that will read key values from an ini file. The key value is pointing to a directory using it's absolute path (example c:\temp). I am attempting to use the String ...
0
votes
0
answers
191
views
How to monitor link with java watchservice
How to monitor a file updated (file is actual.txt below)? But I just want to monitor the link folder.
ln -s ../actual.txt link
Path path = Paths.get(".");
WatchService watchService = path....
0
votes
1
answer
1k
views
Monitoring and Parsing a Log file using Java WatchService
I am trying to monitor a folder to get updates on a specific log file, using the Java WatchService in Java 8.
This log file is created using java.util.logging.Logger and has a regular FileHander, ...
0
votes
0
answers
86
views
How to stop a WatchService by pressing a Button in another JFrame?
I'm a complete noob in java programming and StackOverflow and I always found the answers for my questions by lurking and searching for topics my issues could relate to but it seems I can't find ...
1
vote
2
answers
205
views
Java socket based file transfer application client runs when being debugged but fails when run normally
I have been given a assignment to create a Dropbox like file multi client single server file transfer application. So I created a Server application in java that runs continuously to accept ...
0
votes
0
answers
81
views
Is a single WatchService guaranteed to pick up all incoming files copied in parallel?
I have started working with WatchService to monitor a directory for incoming files. When copying multiple files at the same time, the modification reports can be interlaced and look erratic. My ...
0
votes
1
answer
536
views
JavaFX - How to create a new stage (open new window) when a file is created in specified directory?
I'm pretty new to JavaFX and I'm currently writing a simple GUI application that should react to file creation in a specified directory. So far, I have used WatchService in classic Java apps, but I'm ...
0
votes
0
answers
118
views
How do I end/cancel registration from the below code
I came a cross some code from:
https://www.baeldung.com/java-nio2-watchservice
The topic is regisration to a watchService for changes in directory.
What I am missing from their example is how to ...
4
votes
0
answers
121
views
How many directories can Java WatchService listen to at the same time?
Is this OS related, or there is some limitation in Java that I should be aware of?
fs.inotify.max_user_watches = 524288
0
votes
0
answers
233
views
ExecutorService stops running
I have an ExecutorService that is running a WatchService to monitor when files are changed in a directory and then save a copy of that file. I start the ExecutorService when Tomcat starts using the ...
1
vote
1
answer
126
views
is Java WatchService per JVM or can an app start multiple?
FileSystems.getDefault().newWatchService();
Does that create a new watchService or just give a singleton object?
it says:
@return a new watch service
Some post I read made me think there might ...
-2
votes
2
answers
170
views
How i can make a Watch Service that deletes a file when it closes?
I basically want to make a watch service (or something like it) that checks if a file has been closed and instantly remove that file if it did close(finished executing).
How I can achieve this? ...
4
votes
0
answers
203
views
Can you prevent WatchService from Locking files on Windows?
In Java, if you use the WatchService frameworks to watch the disk for changes, it locks the parents of watched directories, preventing deletion, renaming, etc.
This is an undesirable behavior for my ...
3
votes
1
answer
545
views
Java Watch Service cannot watch more than 50-60 folders defined as UNC Path in Hierarchy
I have been trying to watch folders through UNC. There are a lot of folders in the main folder. When I run the watch service it is registering all the folders with watch service. After all these ...
1
vote
0
answers
128
views
Java WatchService max of 512 registered directories
I'm using the Java WatchService on a Windows box to monitor a network drive, it appears to max out at 512 directories after which even though it registers the folders it doesn't appear to be getting ...
0
votes
3
answers
275
views
How to show only one message for File Change Event Java
When the file structure changes. I keep getting printlns for every single file that was changed. How do I make it so that I only get one println for multiple changes in a 10 second period?
try {
...
0
votes
0
answers
43
views
Java - Find a process responsible for editing a file & kill it if possible?
I've been working on Java's WatchService API to monitor a file directory to see when files have been modified within it. (On Windows). I've got it so that I can see when files are modified.
How can I ...
0
votes
1
answer
108
views
WatchService API events, change editable files (word, odt,....)
I am using the following code to motorize a folder, to get the events of creation, modification, and elimination of files
public static void main(String[] args){
try {
Path dir = Paths....
0
votes
1
answer
1k
views
Java 7 Watch Service cannot detect events properly
I have created a watch service java application using nio2's WatchService for a Linux server whereby I have it watching some directories in a mounted NAS drive. The files will arrive by NFS, MQ or ...
0
votes
1
answer
105
views
WatchService issues - logfile doesn't refresh on modification
I use a (third-party) Windows10 application, which generates .txt log files. In my own application I wrote a class, which uses WatchService and observes the folder for these .txt changes. I know my ...
2
votes
1
answer
930
views
Restart Thread with watching folder
I have thread which is watching folder set in settings file. If I change the settings I would like to stop the thread and start new thread with actual folder to watch. This code is running "fine" but ...
3
votes
2
answers
3k
views
WatchService not polling correctly
I would like to poll a directory every 10 seconds to see if any files have been added or modified. If their are any changes within the 10 seconds I would like to have a set of all file paths that I ...