< prev index next >

src/java.base/share/classes/java/io/File.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad

@@ -255,11 +255,11 @@
      * The parameter order is used to disambiguate this method from the
      * public(File, String) constructor.
      */
     private File(String child, File parent) {
         assert parent.path != null;
-        assert (!parent.path.equals(""));
+        assert (!parent.path.isEmpty());
         this.path = fs.resolve(parent.path, child);
         this.prefixLength = parent.prefixLength;
     }
 
     /**

@@ -314,11 +314,11 @@
     public File(String parent, String child) {
         if (child == null) {
             throw new NullPointerException();
         }
         if (parent != null) {
-            if (parent.equals("")) {
+            if (parent.isEmpty()) {
                 this.path = fs.resolve(fs.getDefaultParent(),
                                        fs.normalize(child));
             } else {
                 this.path = fs.resolve(fs.normalize(parent),
                                        fs.normalize(child));

@@ -357,11 +357,11 @@
     public File(File parent, String child) {
         if (child == null) {
             throw new NullPointerException();
         }
         if (parent != null) {
-            if (parent.path.equals("")) {
+            if (parent.path.isEmpty()) {
                 this.path = fs.resolve(fs.getDefaultParent(),
                                        fs.normalize(child));
             } else {
                 this.path = fs.resolve(parent.path,
                                        fs.normalize(child));

@@ -424,11 +424,11 @@
         if (uri.getRawFragment() != null)
             throw new IllegalArgumentException("URI has a fragment component");
         if (uri.getRawQuery() != null)
             throw new IllegalArgumentException("URI has a query component");
         String p = uri.getPath();
-        if (p.equals(""))
+        if (p.isEmpty())
             throw new IllegalArgumentException("URI path component is empty");
 
         // Okay, now initialize
         p = fs.fromURIPath(p);
         if (File.separatorChar != '/')
< prev index next >