• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to check file content change?

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
There is a remote text file which will be regulary added new lines of text data. I want to remotely check its content. If its content is changed, the new data will be pulled out. What is the best method to check if this file has changed since the last time and pull out new data? Any idea?
regards,
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're running some sort of Java program on the same system as the file (i.e. some sort of server program - JSP/servlet/whatever) then File.lastModified() is probably what you want. If you're talking about trying to learn about this "remote file" from another computer, where you don't have any control over the server's codebase, well, you need to konw what sort of server they're running. Does it accept HTTP requests? FTP? Some custom protocol using sockets? We need more details. (Unless lastModified() was already an adequate answer.)
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Jim:
I am writing both client code and server code (Websphere), so I don't have problem with protocol problem. The client will use HTTP URLConnection to request the server, and get response. A file or directory will be set up on server side to either get input to a file, or write input to the file and insert this file into the directory.
If I use directory-based queue to queue up incoming files, every time the client request asks for new files in the directory, these files will be retrived and sent through response, after that these files will be deleted from the directory, so when the client poll this directory-based queue again, it will get only new files or nothing, I don't have to worry about old content any more.
Is there any way to implement the directory-based file queue?
Any input will be appreciated. Thanks!

Originally posted by Jim Yingst:
If you're running some sort of Java program on the same system as the file (i.e. some sort of server program - JSP/servlet/whatever) then File.lastModified() is probably what you want. If you're talking about trying to learn about this "remote file" from another computer, where you don't have any control over the server's codebase, well, you need to konw what sort of server they're running. Does it accept HTTP requests? FTP? Some custom protocol using sockets? We need more details. (Unless lastModified() was already an adequate answer.)

 
reply
    Bookmark Topic Watch Topic
  • New Topic