Using example Lucene 2.0 index class

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Using example Lucene 2.0 index class

Mag Gam
Hi All,

I have been using the Lucene 2.0 distro Index to index my files, currently
it indexes filepath and contents. I want to index, lastModified() (Returns
the time that the file denoted by this abstract pathname was last
modified.), and file length, length().

Can someone please show me how to do that? I am not too strong with Java,
some example code would be nice!

TIA
Reply | Threaded
Open this post in threaded view
|

Re: Using example Lucene 2.0 index class

Erick Erickson
Ya gotta use google, man <G>. This took about 15 seconds to find by googling

java file modification date

Get the "last modified" date from a file Simply use the lastModified()
method from a file object. but the return value is system dependent and
should only be used to compare with other values returned by last modified.
It should not be interpreted as an absolute time.

String s1 = "file1.dat";
String s2 = "file2.dat";

File f1 = new File(s1);
File f2 = new File(s2);

if (f1.lastModified() < f2.lastModified())
   System.out.println(s1 + " is older than " + s2);



On 9/22/06, Mag Gam <[hidden email]> wrote:

>
> Hi All,
>
> I have been using the Lucene 2.0 distro Index to index my files, currently
> it indexes filepath and contents. I want to index, lastModified() (Returns
> the time that the file denoted by this abstract pathname was last
> modified.), and file length, length().
>
> Can someone please show me how to do that? I am not too strong with Java,
> some example code would be nice!
>
> TIA
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Using example Lucene 2.0 index class

Doron Cohen
In reply to this post by Mag Gam
> I have been using the Lucene 2.0 distro Index to index my files,
currently
> it indexes filepath and contents. I want to index, lastModified()
(Returns
> the time that the file denoted by this abstract pathname was last
> modified.), and file length, length().
>
> Can someone please show me how to do that? I am not too strong with Java,
> some example code would be nice!

IndexFiles in Lucene Demo shows how to index the lastModified info -
-
http://lucene.apache.org/java/docs/api/org/apache/lucene/demo/IndexFiles.html
-
http://lucene.apache.org/java/docs/api/org/apache/lucene/demo/FileDocument.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Using example Lucene 2.0 index class

Doron Cohen
> > I have been using the Lucene 2.0 distro Index to index my
> > files, currently it indexes filepath and contents. I want
> > to index, lastModified() (Returns the time that the file
> > denoted by this abstract pathname was last
> > modified.), and file length, length().
> >
> > Can someone please show me how to do that? I am not
> > too strong with Java, some example code would be nice!
>
> IndexFiles in Lucene Demo shows how to index the lastModified info
>
http://lucene.apache.org/java/docs/api/org/apache/lucene/demo/IndexFiles.html

> http://lucene.apache.>
org/java/docs/api/org/apache/lucene/demo/FileDocument.html

Forgot to mention, if you don't have the sources already, you can see the
demo sources in
http://svn.apache.org/viewvc/lucene/java/tags/lucene_2_0_0/src/demo/org/apache/lucene/demo/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Using example Lucene 2.0 index class

Mark Miller-3
In reply to this post by Erick Erickson
Not to step out of Lucene world, but I would love to know the truth of
the matter on this...the first site that search brings up on google
seems to claim that was the behavior back at 1.2 or so and it is not the
case anymore.

The javadocs don't seem to mention it:


      lastModified

public long *lastModified*()

    Returns the time that the file denoted by this abstract pathname was
    last modified.

    *Returns:*
        A |long| value representing the time the file was last modified,
        measured in milliseconds since the epoch (00:00:00 GMT, January
        1, 1970), or |0L| if the file does not exist or if an I/O error
        occurs
    *Throws:*
        |SecurityException
        <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/SecurityException.html>|
        - If a security manager exists and its
        ||SecurityManager.checkRead(java.lang.String)|
        <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/SecurityManager.html#checkRead%28java.lang.String%29>|
        method denies read access to the file



Erick Erickson wrote:

> Ya gotta use google, man <G>. This took about 15 seconds to find by
> googling
>
> java file modification date
>
> Get the "last modified" date from a file Simply use the lastModified()
> method from a file object. but the return value is system dependent and
> should only be used to compare with other values returned by last
> modified.
> It should not be interpreted as an absolute time.
>
> String s1 = "file1.dat";
> String s2 = "file2.dat";
>
> File f1 = new File(s1);
> File f2 = new File(s2);
>
> if (f1.lastModified() < f2.lastModified())
>   System.out.println(s1 + " is older than " + s2);
>
>
>
> On 9/22/06, Mag Gam <[hidden email]> wrote:
>>
>> Hi All,
>>
>> I have been using the Lucene 2.0 distro Index to index my files,
>> currently
>> it indexes filepath and contents. I want to index, lastModified()
>> (Returns
>> the time that the file denoted by this abstract pathname was last
>> modified.), and file length, length().
>>
>> Can someone please show me how to do that? I am not too strong with
>> Java,
>> some example code would be nice!
>>
>> TIA
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]