src/java.base/share/classes/java/io/File.java
changeset 52902 e3398b2e1ab0
parent 52220 9c260a6b6471
child 53258 e348b0160d61
equal deleted inserted replaced
52901:3ba9ff4d4aaf 52902:e3398b2e1ab0
   255      * The parameter order is used to disambiguate this method from the
   255      * The parameter order is used to disambiguate this method from the
   256      * public(File, String) constructor.
   256      * public(File, String) constructor.
   257      */
   257      */
   258     private File(String child, File parent) {
   258     private File(String child, File parent) {
   259         assert parent.path != null;
   259         assert parent.path != null;
   260         assert (!parent.path.equals(""));
   260         assert (!parent.path.isEmpty());
   261         this.path = fs.resolve(parent.path, child);
   261         this.path = fs.resolve(parent.path, child);
   262         this.prefixLength = parent.prefixLength;
   262         this.prefixLength = parent.prefixLength;
   263     }
   263     }
   264 
   264 
   265     /**
   265     /**
   314     public File(String parent, String child) {
   314     public File(String parent, String child) {
   315         if (child == null) {
   315         if (child == null) {
   316             throw new NullPointerException();
   316             throw new NullPointerException();
   317         }
   317         }
   318         if (parent != null) {
   318         if (parent != null) {
   319             if (parent.equals("")) {
   319             if (parent.isEmpty()) {
   320                 this.path = fs.resolve(fs.getDefaultParent(),
   320                 this.path = fs.resolve(fs.getDefaultParent(),
   321                                        fs.normalize(child));
   321                                        fs.normalize(child));
   322             } else {
   322             } else {
   323                 this.path = fs.resolve(fs.normalize(parent),
   323                 this.path = fs.resolve(fs.normalize(parent),
   324                                        fs.normalize(child));
   324                                        fs.normalize(child));
   357     public File(File parent, String child) {
   357     public File(File parent, String child) {
   358         if (child == null) {
   358         if (child == null) {
   359             throw new NullPointerException();
   359             throw new NullPointerException();
   360         }
   360         }
   361         if (parent != null) {
   361         if (parent != null) {
   362             if (parent.path.equals("")) {
   362             if (parent.path.isEmpty()) {
   363                 this.path = fs.resolve(fs.getDefaultParent(),
   363                 this.path = fs.resolve(fs.getDefaultParent(),
   364                                        fs.normalize(child));
   364                                        fs.normalize(child));
   365             } else {
   365             } else {
   366                 this.path = fs.resolve(parent.path,
   366                 this.path = fs.resolve(parent.path,
   367                                        fs.normalize(child));
   367                                        fs.normalize(child));
   424         if (uri.getRawFragment() != null)
   424         if (uri.getRawFragment() != null)
   425             throw new IllegalArgumentException("URI has a fragment component");
   425             throw new IllegalArgumentException("URI has a fragment component");
   426         if (uri.getRawQuery() != null)
   426         if (uri.getRawQuery() != null)
   427             throw new IllegalArgumentException("URI has a query component");
   427             throw new IllegalArgumentException("URI has a query component");
   428         String p = uri.getPath();
   428         String p = uri.getPath();
   429         if (p.equals(""))
   429         if (p.isEmpty())
   430             throw new IllegalArgumentException("URI path component is empty");
   430             throw new IllegalArgumentException("URI path component is empty");
   431 
   431 
   432         // Okay, now initialize
   432         // Okay, now initialize
   433         p = fs.fromURIPath(p);
   433         p = fs.fromURIPath(p);
   434         if (File.separatorChar != '/')
   434         if (File.separatorChar != '/')