Results 1 to 2 of 2
  1. #1
    suvojit168 is offline Member
    Join Date
    Jul 2009
    Rep Power

    Question Question about File renameTo() method : Abnormal output

    public static void main(String[] args) throws Exception
    File fl1 = new File("D:/Education/Java/Test1");
    File fl2 = new File("D:/Education/Java/Test2");
    p("New File Name is : "+ fl1.getName());

    For the above code snippet O/P is
    New File Name is : Test1
    BUILD SUCCESSFUL (total time: 2 seconds)

    My question is :
    At my system although the Test1 gets renamed as Test2 after compilation but still fl1.getName() returns the old name Test1. Why so?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Rep Power


    Read the caveats for this method in the Method Detail section of the File api.

Similar Threads

  1. problem with output of jar file
    By nishant.4545 in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2009, 05:00 PM
  2. No output to file
    By shiva in forum Java Servlet
    Replies: 0
    Last Post: 04-24-2009, 03:06 PM
  3. Output to a text file
    By sfe23 in forum New To Java
    Replies: 4
    Last Post: 03-26-2009, 11:44 PM
  4. Replies: 7
    Last Post: 11-19-2008, 03:09 PM
  5. invoking method and output questions
    By bluekswing in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts