< prev index next >

src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java

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

@@ -206,11 +206,11 @@
                             RESOURCE.getString(DriverResource.BAD_OPTION),
                             opt, avProps.get(opt)));
             }
         }
 
-        if (logFile != null && !logFile.equals("")) {
+        if (logFile != null && !logFile.isEmpty()) {
             if (logFile.equals("-")) {
                 System.setErr(System.out);
             } else {
                 OutputStream log = new FileOutputStream(logFile);
                 //log = new BufferedOutputStream(out);

@@ -244,11 +244,11 @@
                 printUsage(doPack, false, System.err);
                 System.exit(2);
             }
             newfile = packfile;
             // The optional second argument is the source JAR file.
-            if (jarfile.equals("")) {
+            if (jarfile.isEmpty()) {
                 // If only one file is given, it is the only JAR.
                 // It serves as both input and output.
                 jarfile = newfile;
             }
             tmpfile = createTempFile(newfile, ".pack").getPath();

@@ -350,11 +350,11 @@
                 BufferedInputStream inBuf = new BufferedInputStream(in);
                 in = inBuf;
                 if (Utils.isGZIPMagic(Utils.readMagic(inBuf))) {
                     in = new GZIPInputStream(in);
                 }
-                String outfile = newfile.equals("")? jarfile: newfile;
+                String outfile = newfile.isEmpty()? jarfile: newfile;
                 OutputStream fileOut;
                 if (outfile.equals("-"))
                     fileOut = System.out;
                 else
                     fileOut = new FileOutputStream(outfile);

@@ -364,25 +364,25 @@
                     // p200 closes in but not out
                 }
                 // At this point, we have a good jarfile (or newfile, if -r)
             }
 
-            if (!bakfile.equals("")) {
+            if (!bakfile.isEmpty()) {
                         // On success, abort jarfile recovery bracket.
                         new File(bakfile).delete();
                         bakfile = "";
             }
 
         } finally {
             // Close jarfile recovery bracket.
-            if (!bakfile.equals("")) {
+            if (!bakfile.isEmpty()) {
                 File jarFile = new File(jarfile);
                 jarFile.delete(); // Win32 requires this, see above
                 new File(bakfile).renameTo(jarFile);
             }
             // In all cases, delete temporary *.pack.
-            if (!tmpfile.equals(""))
+            if (!tmpfile.isEmpty())
                 new File(tmpfile).delete();
         }
     }
 
     private static
< prev index next >