file.lastmodified

S

Steve Rainbird

Why on my Windows Vista box does file.lastmodified() always return zero but
on my Linux box it returns the correct value?
 
A

Andrew Thompson

Why on my Windows Vista box does file.lastmodified()

Did you mean the File.lastModified() method?
I have not heard of the other one and cannot
comment on it.
.. always return zero but
on my Linux box it returns the correct value?

What does this print on the Vista box?

<sscce>
public class LastModified {

public static void main(String[] args) {
java.io.File file = new
java.io.File("LastModified.java");
System.out.println( file.lastModified() );
}
}
<sscce>

BTW - did you read the JavaDocs for that method?
There are two reasons listed, as to why the method
may return '0'.
 
S

Steve Rainbird

Andrew Thompson said:
Why on my Windows Vista box does file.lastmodified()

Did you mean the File.lastModified() method?
I have not heard of the other one and cannot
comment on it.
.. always return zero but
on my Linux box it returns the correct value?

What does this print on the Vista box?

<sscce>
public class LastModified {

public static void main(String[] args) {
java.io.File file = new
java.io.File("LastModified.java");
System.out.println( file.lastModified() );
}
}
<sscce>

BTW - did you read the JavaDocs for that method?
There are two reasons listed, as to why the method
may return '0'.


Andrew,

Thanks ,that displays the correct result. I think it must be a permissions
problem. I will look into it further.
 
S

Steve Rainbird

Steve Rainbird said:
Andrew Thompson said:
Why on my Windows Vista box does file.lastmodified()

Did you mean the File.lastModified() method?
I have not heard of the other one and cannot
comment on it.
.. always return zero but
on my Linux box it returns the correct value?

What does this print on the Vista box?

<sscce>
public class LastModified {

public static void main(String[] args) {
java.io.File file = new
java.io.File("LastModified.java");
System.out.println( file.lastModified() );
}
}
<sscce>

BTW - did you read the JavaDocs for that method?
There are two reasons listed, as to why the method
may return '0'.


Andrew,

Thanks ,that displays the correct result. I think it must be a
permissions problem. I will look into it further.

Fixed it.

I was getting a directory listing and then trying to find out the
LastModified of those files. But I forgot to add the path onto the
beginning of the file name.

Linux worked because I was looking for files in the current directory.

DOH!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top