< prev index next >

src/java.base/windows/classes/sun/nio/fs/WindowsPath.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

@@ -241,11 +241,11 @@
         // Drive relative path ("C:foo" for example).
         if (isSameDrive(root, getFileSystem().defaultRoot())) {
             // relative to default directory
             String remaining = path.substring(root.length());
             String defaultDirectory = getFileSystem().defaultDirectory();
-            if (remaining.length() == 0) {
+            if (remaining.isEmpty()) {
                 return defaultDirectory;
             } else if (defaultDirectory.endsWith("\\")) {
                  return defaultDirectory + remaining;
             } else {
                 return defaultDirectory + "\\" + remaining;

@@ -297,11 +297,11 @@
     }
 
     // -- Path operations --
 
     private boolean isEmpty() {
-        return path.length() == 0;
+        return path.isEmpty();
     }
 
     private WindowsPath emptyPath() {
         return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", "");
     }

@@ -338,11 +338,11 @@
                                    path.substring(0, off));
     }
 
     @Override
     public WindowsPath getRoot() {
-        if (root.length() == 0)
+        if (root.isEmpty())
             return null;
         return new WindowsPath(getFileSystem(), type, root, root);
     }
 
     // package-private

@@ -554,11 +554,11 @@
         if (remaining == count)
             return this;
 
         // corner case - all names removed
         if (remaining == 0) {
-            return (root.length() == 0) ? emptyPath() : getRoot();
+            return root.isEmpty() ? emptyPath() : getRoot();
         }
 
         // re-constitute the path from the remaining names.
         StringBuilder result = new StringBuilder();
         if (root != null)
< prev index next >