Home arrow static arrow Java Programming [Archive] - Track File Usage in Java
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Track File Usage in Java
This topic has 23 replies on 2 pages.    1 | 2 | Next »

Posts:79
Registered: 5/1/02
Track File Usage in Java  
Aug 3, 2004 9:12 AM



 
Hi. Is it possible to track the number times a file is accessed/viewed in Java? I need this functionality to the new requirements for our project. Wherein the user will have an option to delete files that are less used/viewed.

Any help will be greatly appreciated. Thanks!!
 

Posts:403
Registered: 9/4/03
Re: Track File Usage in Java  
Aug 3, 2004 10:00 AM (reply 1 of 23)



 
If the file access is only granted through your application, then yes. Simply put a counter in your code for everytime a user accesses each file.

But if file access can be obtained from anywhere, then no. At least not in a practical way. I suppose you could constantly monitor the files and check their last access times, but this is silly.

Perhaps maybe you should just allow a user to have an option to delete files that have not been accessed in x number of days. Rather than less used/viewed. Say 30 days? Whatever your requirements are.
 

Posts:79
Registered: 5/1/02
Re: Track File Usage in Java  
Aug 3, 2004 10:18 AM (reply 2 of 23)



 
File access is not granted by the application which makes things really difficult. The application is a download manager - an applet that connects to the server and stores files in ur computer. They already have the number of days option and would like to add an option about deleting rarely used files.

Thanks a lot for the input. But, is there any way at all? I would like to present these options to my boss if there are any. As of the moment, I have been researching and found no possible way of doing this.
 

Posts:79
Registered: 5/1/02
Re: Track File Usage in Java  
Aug 3, 2004 10:19 AM (reply 3 of 23)



 
Repost:

File access is not granted by the application which makes things really difficult. The application is a download manager - an applet that connects to the server and stores files in ur computer. They already have the number of days option and would like to add an option about deleting rarely used files.

Thanks a lot for the input. But, is there any way at all? I would like to present these options to my boss if there are any. As of the moment, I have been researching and found no possible way of doing this through java..
 

Posts:31,095
Registered: 4/30/99
Re: Track File Usage in Java  
Aug 3, 2004 10:30 AM (reply 4 of 23)



 
The application is a
download manager - an applet that connects to the
server and stores files in ur computer. They already
have the number of days option and would like to add
an option about deleting rarely used files.

Then the download manager would have to have somewhere to store the "number of times used" counter for each file. A database on the server might be one possibility.

PC²
 

Posts:79
Registered: 5/1/02
Re: Track File Usage in Java  
Aug 3, 2004 10:40 AM (reply 5 of 23)



 
Hmm...but the thing is the user can open these files using Winamp or Windows Media Player (or any compatible software) in their local machine. Is there any way to keep track of how many times the user did this and store it in a txt file for instance? Thanks!
 

Posts:31,095
Registered: 4/30/99
Re: Track File Usage in Java  
Aug 3, 2004 10:45 AM (reply 6 of 23)



 
Basically, no. If you aren't controlling access to the files then you can't keep track of how often they are accessed. And most operating systems that I know don't do that either.
 

Posts:14,142
Registered: 99-04-02
Re: Track File Usage in Java  
Aug 3, 2004 10:57 AM (reply 7 of 23)



 
where does it get the files? if you have it saving to the user's PC, there's nothing you can do. IF your app has to get the file from the server every time, then you can do a count.

Although, if it's MP3 files and other formats that might use ID3 tags (or some formats) there are fields in the file for counting how many times a file is played. But that is up to the player app to do that.
 

Posts:79
Registered: 5/1/02
Re: Track File Usage in Java  
Aug 3, 2004 11:09 AM (reply 8 of 23)



 
It gets the files from a server and stores it in user's local machine. We have to know the number of times the user accesses these files in his/her local machine and not on the server. So I guess that's pretty hard or impossible through Java at least. These are video files by the way.
 

Posts:14,142
Registered: 99-04-02
Re: Track File Usage in Java  
Aug 3, 2004 11:12 AM (reply 9 of 23)



 
unless you can control the player as well, which could report back to the server what it's playing... but if you are using Winamp or some other player that you don't provide, I really don't see any way to do this type of thing... at least without doing complex stuff with OS specific stuff that would probably get in the way anyway, and if I found something like that on my PC, I'd kill it.
 

Posts:19,725
Registered: 9/26/01
Re: Track File Usage in Java  
Aug 3, 2004 11:16 AM (reply 10 of 23)



 
It gets the files from a server and stores it in
user's local machine. We have to know the number of
times the user accesses these files in his/her local
machine
and not on the server. So I guess that's
pretty hard or impossible through Java at least. These
are video files by the way.

That "requirement" is nonsense. Also suppose the user copies the file to an external device and access it there. Does that count as another "access"?
 

Posts:79
Registered: 5/1/02
Re: Track File Usage in Java  
Aug 3, 2004 11:44 AM (reply 11 of 23)



 
It's not really nonsense if the user would prefer that the application delete files in a specified directory if he/she doesnt use it often. Thanks for input guys. Feel free to post =)
 

Posts:2,206
Registered: 8/15/02
Re: Track File Usage in Java  
Aug 3, 2004 11:48 AM (reply 12 of 23)



 
It's not really nonsense if the user would prefer that
the application delete files in a specified
directory
if he/she doesnt use it often. Thanks
for input guys. Feel free to post =)

Surely then the last access time is sufficient.
 

Posts:19,725
Registered: 9/26/01
Re: Track File Usage in Java  
Aug 3, 2004 11:50 AM (reply 13 of 23)



 
It's not really nonsense if the user would prefer that
the application delete files in a specified
directory
if he/she doesnt use it often. Thanks
for input guys. Feel free to post =)

Then, if all access to the file(s) is still not controlled thru a central app, you'd have to write some low-level boot-time/logon-time service (it wouldn't be a Java thing) that would hook into the OS to observe every file access attempt (like virus scanners can do) and update some data source keeping track of such attempts.
 

Posts:19,725
Registered: 9/26/01
Re: Track File Usage in Java  
Aug 3, 2004 11:51 AM (reply 14 of 23)



 
It's not really nonsense if the user would prefer
that
the application delete files in a specified
directory
if he/she doesnt use it often. Thanks
for input guys. Feel free to post =)

Surely then the last access time is sufficient.

Not really.
1) That wouldn't count frequency
2) As soon as you access the file to get its last access time, guess what? You've updated the last access time.
 
This topic has 23 replies on 2 pages.    1 | 2 | Next »