file.lastmodified

Discussion in 'Java' started by Steve Rainbird, Jul 18, 2008.

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

    --
    Steve
    Steve Rainbird, Jul 18, 2008
    #1
    1. Advertising

  2. On Jul 19, 12:45 am, "Steve Rainbird"
    <> 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 Thompson, Jul 18, 2008
    #2
    1. Advertising

  3. "Andrew Thompson" <> wrote in message
    news:...
    > On Jul 19, 12:45 am, "Steve Rainbird"
    > <> 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
    Steve Rainbird, Jul 18, 2008
    #3
  4. In article <>,
    "Steve Rainbird" <> 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
    John B. Matthews, Jul 18, 2008
    #4
  5. "Steve Rainbird" <> wrote in message
    news:...
    >
    >
    > "Andrew Thompson" <> wrote in message
    > news:...
    >> On Jul 19, 12:45 am, "Steve Rainbird"
    >> <> 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
    Steve Rainbird, Jul 18, 2008
    #5
  6. Steve Rainbird

    Roedy Green Guest

    On Fri, 18 Jul 2008 15:45:54 +0100, "Steve Rainbird"
    <> 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
    Roedy Green, Jul 19, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kenneth Keeley

    Trying to display LastModified Data.

    Kenneth Keeley, Apr 13, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    322
    Kenneth Keeley
    Apr 13, 2005
  2. szymex
    Replies:
    3
    Views:
    451
    Andrew Thompson
    Apr 25, 2004
  3. Robert Mischke

    File.lastModified *extremely* slow ?

    Robert Mischke, Aug 29, 2004, in forum: Java
    Replies:
    38
    Views:
    2,363
    Chris Uppal
    Sep 3, 2004
  4. Bart
    Replies:
    12
    Views:
    209
    Dr John Stockton
    Feb 9, 2004
  5. Pugi!

    lastModified from file on clientside

    Pugi!, Nov 24, 2006, in forum: Javascript
    Replies:
    1
    Views:
    75
Loading...

Share This Page