wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Getting File Date w/o Changing Access Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Getting File Date w/o Changing Access Tag" Watch "Getting File Date w/o Changing Access Tag" New topic
Author

Getting File Date w/o Changing Access Tag

Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
We're looking at deleting all files on a unix file system that haven't been used in x amount of time. Here's the code we currently use in our jsp:



The problem on unix is, if you touch the files to get the file's load date, it changes the access timestamp for the file. I can't find anything on how to read the timestamp via Java/jsp without changing any of the file's underlying information.

Thanks for your help.

[ March 25, 2007: Message edited by: Pat Flickner ]
[ March 25, 2007: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

This has absoluely nothing to do with JSP. Moved to an appropriate forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
Sorry, the code is in my jsp and it didn't occur to me that this might not be a jsp question.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Putting aside the fact that in this day and age you shouldn't be putting any code at all in a JSP, if it isn't about JSP technology, which this clearly is not, it isn't a JSP question.
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
Actually, I inherited the code, Bear, and to be quite honest, with the integration project and a myriad of real problems I've had to address, I haven't had the time to correct all past mistakes, although I have corrected quite a few. This one seemed very low priority considering the overhaul we've had to do. So if could you just ease up a teensy bit, I'd really appreciate it. I'm just looking for answers. If this piece of code were within a servlet -- which it will be eventually -- I would still have need of the answer. You will be pleased to know that a rewrite of this project, partly for the reason you very aptly point out.

Thank you for your help.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Pat Flickner:
I can't find anything on how to read the timestamp via Java/jsp without changing any of the file's underlying information.
I would have thought that the lastModified() method just returned the last modified date, without changing anything else. Are you saying that's not the case in Unix?
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
In unix, any time you get info about a file, it changes the access timestamp. I'm not sure if the lastModified() method does that without affecting anything else.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Originally posted by Pat Flickner:
I'm not sure if the lastModified() method does that without affecting anything else.


Seems enough enough to test.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting File Date w/o Changing Access Tag
 
Similar Threads
change data type from string to timestamp
NullPointerException in JSP after calling Servlet method
Showing Date if no value
comparing date
Date/Time conversion to GMT with DayLightSavings