doubt on renameTo method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itsraghz
    New Member
    • Mar 2007
    • 124

    #1

    doubt on renameTo method

    Hi ,

    While looking at this thread http://bytes.com/forum/showthread.php?threadid=851452 , just got to know about the new method "renameTo()". Was wondering for having missed this and wanted to check that out. [Thanks to the admin r035198x!]

    The API says that ,

    Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists.
    I am very sure that there is NO file with the passed destination file name. But the return value is always false and it shows the operation failed.

    Any idea/clue? I am using it in Windows OS.

    Thanks,
    Raghavan alias Saravanan M.
    Last edited by itsraghz; Nov 6 '08, 12:30 PM. Reason: spelling mistake
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Are both the source and the target file on the same file system (or 'disk')?

    kind regards,

    Jos

    Comment

    • itsraghz
      New Member
      • Mar 2007
      • 124

      #3
      Originally posted by JosAH
      Are both the source and the target file on the same file system (or 'disk')?

      kind regards,

      Jos
      Yes Jos. Thank you. They both are in the same file system/disk.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        ... and you have permissions to both source and destination folders?

        Comment

        • itsraghz
          New Member
          • Mar 2007
          • 124

          #5
          Originally posted by r035198x
          ... and you have permissions to both source and destination folders?
          yes of course. I do have the admin rights (part of administrator group)!

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Could you give us a peek at the code then?

            Comment

            • itsraghz
              New Member
              • Mar 2007
              • 124

              #7
              Originally posted by r035198x
              Could you give us a peek at the code then?
              Thank you r035198x.

              It was a confusion in the classpath settings of the IDE I use Netbeans.

              After changing the files in the appropriate classpath, it works fine!

              I had to ensure first by doing it in command prompt - same old better way of dealing with Java programs!
              Last edited by itsraghz; Nov 6 '08, 02:23 PM. Reason: moving one confusion into a different thread!

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by itsraghz
                Thank you r035198x.

                It was a confusion in the classpath settings of the IDE I use Netbeans.

                After changing the files in the appropriate classpath, it works fine!

                I had to ensure first by doing it in command prompt - same old better way of dealing with Java programs!
                I don't understand what a classpath has to do with an assumed failure/success
                of the renameTo() method.

                kind regards,

                Jos

                Comment

                • Nepomuk
                  Recognized Expert Specialist
                  • Aug 2007
                  • 3111

                  #9
                  Originally posted by JosAH
                  I don't understand what a classpath has to do with an assumed failure/success of the renameTo() method.
                  I'd say: relative paths! :-D

                  Greetings,
                  Nepomuk

                  Comment

                  Working...