Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4042592

java.io.File.renameTo should work with non-canonical pathnames

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      x86, sparc
    • OS:
      generic, solaris_2.5.1, windows_95
    • Verification:
      Verified

      Backports

        Description



        Name: akC57697 Date: 04/02/97



        The java.io.File renameTo() does not work properly with non-canonical
        pathnames.The method should convert given pathname to canonical one,
        then rename.
                                          
        ______________________ TestRenNeg.java _________________________________
        import java.io.*;
        public class TestRenNeg {
          public static void main(String[] args){

              try {
               File f1 = new File("\\c:\\From");
               File f2 = new File("\\c:\\To");

               if (f1.exists() || f2.exists() ) {
                System.out.println("Test not applicable - directories exist ");
                return;
               }

               System.out.println("Create :"+f1.mkdir());
               System.out.println("Does it exist as directory ? :"+f1.exists()+" "+f1.isDirectory());
               System.out.println("Rename:" +f1.renameTo(f2));
             } catch (Exception e) {System.out.println("Unexpected "+e);}
         }
        }
        ______________________ Output ________________________________________
        Create :true
        Does it exist as directory ? :true true
        Rename:false
        ______________________________________________________________________
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                mmcclosksunw Michael Mccloskey (Inactive)
                Reporter:
                akuzminorcl Alexander Kuzmin (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: