Article View: borland.public.jbuilder.java.api
Article #301Re: monitoring directory tree changes
From: Shankar Unni
Date: Fri, 02 Jan 2004 20:40
Date: Fri, 02 Jan 2004 20:40
18 lines
1869 bytes
1869 bytes
gary wrote:
> in C, i'd probably just traverse directories doing stat()
> calls and looking at timestamps,
Oh, hey, if you're willing to do that, there's a portable way to do it:
use the java.io.File class.
File has a lot of "stat"-like information, and you can use
File.listFiles() to list all the Files under a File which corresponds to
a directory (e.g. new File("c:\\temp").listFiles()). Just walk the
array, and look at the lastModified() time. Be prepared to test
isDirectory() and recursively walk any subdirectories.
This is definitely not efficient, either time or memory wise (the
listFiles() will do a full ls -d inside the directory and return you one
giant list, so if you have 100000 files in that directory, watch out).
But it's quite portable.
Technical Details
Message-ID:
<3ff5d72c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3FF24822.90104@cordelli.net> <3ff34c61$1@newsgroups.borland.com> <3FF38F41.401@cordelli.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,760bdf7d8953e8c9 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2004-01-02 13:10:10 PST Date: Fri, 02 Jan 2004 12:40:12 -0800 From: Shankar Unni <shankarunni@netscape.net> User-Agent: Mozilla Thunderbird 0.5a (20031223) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.api Subject: Re: monitoring directory tree changes References: <3FF24822.90104@cordelli.net> <3ff34c61$1@newsgroups.borland.com> <3FF38F41.401@cordelli.net> In-Reply-To: <3FF38F41.401@cordelli.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 68.122.117.115 Message-ID: <3ff5d72c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1073076012 68.122.117.115 (2 Jan 2004 12:40:12 -0700) Lines: 18 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail