Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Access from a Directory.  RSS feed

 
Dravit Gupta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

In my program I am browsing a file from a particular folder and than taking data of that file and updating database. But the file is generated by a third party software and file get itself changed after sometime and saved by another name.
Please suggest me how to watch that particular directory for any new file, so that my program can automatically find that updated file and I don't need to browse for new file again and again.

Please reply as soon as possible.

Thanks in advance.

-Dravit Gupta
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Welcome to the Ranch!

Dravit Gupta wrote:Please reply as soon as possible.

Please remember that people here volunteer thier time to provide you answers. So, ease up

As for the problem, if you are using JDK 1.7, you have to write a watch service. This has already been discussed here.
 
Dravit Gupta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

I really found that example and details helpful.

But one thing that I want is, if the application is not running and a file or more is created in that directory at that time, than when user start the application after some time, automatically he should get a notification that new files were created (excluding the previous one's which already were monitored) or those files automatically get updated to the database without any notification.

Thank You.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Ranganathan already told you what you need to do, and provided a link for more information.

So, problem solved?
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dravit Gupta wrote: if the application is not running and a file or more is created in that directory at that time, than when user start the application after some time, automatically he should get a notification that new files were created (excluding the previous one's which already were monitored) or those files automatically get updated to the database without any notification.


No need to use Bold font to ask additional questions. Do read this.

As for the question, this is just application logic...which you will have to handle. When the application shuts down, you should store the current state (say file names). When the application starts up, you should read this and compare against the current contents.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!