?
Solved

Help wanted with Filewatcher Java

Posted on 2015-01-28
3
Medium Priority
?
77 Views
Last Modified: 2015-07-07
Hi experts. I'm working on a code to handle files with the java file watcher. Got it working, except sometimes it's throwing on exception saying the file is in use. strangely this is always the last of the pasted files. I'm sure it is not in use..well not be me anyway.

Any ideas?
0
Comment
Question by:HPvH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Expert Comment

by:Amitkumar Panchal
ID: 40576693
Generally, it comes when a file (a handle to a file) is in use by some other process. So, you will need to check for which file the exception is encountered and see if it used by another process.

By the way, can I ask what the file watcher do ? Any associated activity (or file processing) with file watcher ?
0
 

Author Comment

by:HPvH
ID: 40583476
hi Panchal,

Thank you for your response and sorry for my late reaction. I'm using file watcher, because I want a program to watch a folder and act immediately when a file is dropped there. After picking up the file I look at the content and put it in a other folder, after some DB actions, for further handling.

I prefer not to use a cronjob to start program and handle file.
0
 
LVL 13

Accepted Solution

by:
George K. earned 1500 total points
ID: 40629473
Hi,
Create a handle:
public void handle(FileSystemEvent event)

......

then get the info you need:
new Object[]{event.getFileInfo(), actionName}
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
A solution for Fortify Path Manipulation.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question