Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > file.lastmodified

Reply
Thread Tools

file.lastmodified

 
 
Steve Rainbird
Guest
Posts: n/a
 
      07-18-2008
Why on my Windows Vista box does file.lastmodified() always return zero but
on my Linux box it returns the correct value?

--
Steve

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      07-18-2008
On Jul 19, 12:45*am, "Steve Rainbird"
<(E-Mail Removed)> wrote:
> 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 Thompson
http://pscode.org/
 
Reply With Quote
 
 
 
 
Steve Rainbird
Guest
Posts: n/a
 
      07-18-2008


"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Jul 19, 12:45 am, "Steve Rainbird"
> <(E-Mail Removed)> wrote:
>> 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 Thompson
> http://pscode.org/



Andrew,

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

--
Steve

 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      07-18-2008
In article <(E-Mail Removed)>,
"Steve Rainbird" <(E-Mail Removed)> wrote:

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


Does the file exit? Has an I/O error occurred?

<http://java.sun.com/javase/6/docs/api/java/io/File.html#lastModified()>

--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
 
Reply With Quote
 
Steve Rainbird
Guest
Posts: n/a
 
      07-18-2008


"Steve Rainbird" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> "Andrew Thompson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> On Jul 19, 12:45 am, "Steve Rainbird"
>> <(E-Mail Removed)> wrote:
>>> 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 Thompson
>> http://pscode.org/

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


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!


--
Steve

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-19-2008
On Fri, 18 Jul 2008 15:45:54 +0100, "Steve Rainbird"
<(E-Mail Removed)> wrote, quoted or indirectly
quoted someone who said :

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


Works fine on my Vista box. Have you an sscce to prove the bug.

See http://mindprod.com/jgloss/sscce.html

Do you have permission to look at the file in question?
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments