< 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,216 ****
RESOURCE.getString(DriverResource.BAD_OPTION),
opt, avProps.get(opt)));
}
}
! if (logFile != null && !logFile.equals("")) {
if (logFile.equals("-")) {
System.setErr(System.out);
} else {
OutputStream log = new FileOutputStream(logFile);
//log = new BufferedOutputStream(out);
--- 206,216 ----
RESOURCE.getString(DriverResource.BAD_OPTION),
opt, avProps.get(opt)));
}
}
! if (logFile != null && !logFile.isEmpty()) {
if (logFile.equals("-")) {
System.setErr(System.out);
} else {
OutputStream log = new FileOutputStream(logFile);
//log = new BufferedOutputStream(out);
*** 244,254 ****
printUsage(doPack, false, System.err);
System.exit(2);
}
newfile = packfile;
// The optional second argument is the source JAR file.
! if (jarfile.equals("")) {
// 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();
--- 244,254 ----
printUsage(doPack, false, System.err);
System.exit(2);
}
newfile = packfile;
// The optional second argument is the source JAR file.
! 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,360 ****
BufferedInputStream inBuf = new BufferedInputStream(in);
in = inBuf;
if (Utils.isGZIPMagic(Utils.readMagic(inBuf))) {
in = new GZIPInputStream(in);
}
! String outfile = newfile.equals("")? jarfile: newfile;
OutputStream fileOut;
if (outfile.equals("-"))
fileOut = System.out;
else
fileOut = new FileOutputStream(outfile);
--- 350,360 ----
BufferedInputStream inBuf = new BufferedInputStream(in);
in = inBuf;
if (Utils.isGZIPMagic(Utils.readMagic(inBuf))) {
in = new GZIPInputStream(in);
}
! String outfile = newfile.isEmpty()? jarfile: newfile;
OutputStream fileOut;
if (outfile.equals("-"))
fileOut = System.out;
else
fileOut = new FileOutputStream(outfile);
*** 364,388 ****
// p200 closes in but not out
}
// At this point, we have a good jarfile (or newfile, if -r)
}
! if (!bakfile.equals("")) {
// On success, abort jarfile recovery bracket.
new File(bakfile).delete();
bakfile = "";
}
} finally {
// Close jarfile recovery bracket.
! if (!bakfile.equals("")) {
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(""))
new File(tmpfile).delete();
}
}
private static
--- 364,388 ----
// p200 closes in but not out
}
// At this point, we have a good jarfile (or newfile, if -r)
}
! if (!bakfile.isEmpty()) {
// On success, abort jarfile recovery bracket.
new File(bakfile).delete();
bakfile = "";
}
} finally {
// Close jarfile recovery bracket.
! 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.isEmpty())
new File(tmpfile).delete();
}
}
private static
< prev index next >