src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
Print this page
@@ -94,16 +94,18 @@
}
//Driver routines
// The unpack worker...
+
/**
* Takes a packed-stream InputStream, and writes to a JarOutputStream. Internally
* the entire buffer must be read, it may be more efficient to read the packed-stream
* to a file and pass the File object, in the alternate method described below.
* <p>
* Closes its input but not its output. (The output can accumulate more elements.)
+ *
* @param in an InputStream.
* @param out a JarOutputStream.
* @exception IOException if an error is encountered.
*/
public synchronized void unpack(InputStream in, JarOutputStream out) throws IOException {
@@ -111,23 +113,23 @@
throw new NullPointerException("null input");
}
if (out == null) {
throw new NullPointerException("null output");
}
- assert(Utils.currentInstance.get() == null);
- TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
- ? null
- : TimeZone.getDefault();
-
+ assert (Utils.currentInstance.get() == null);
+ boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
try {
Utils.currentInstance.set(this);
- if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ if (needUTC) {
+ Utils.changeDefaultTimeZoneToUtc();
+ }
final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
BufferedInputStream in0 = new BufferedInputStream(in);
if (Utils.isJarMagic(Utils.readMagic(in0))) {
- if (verbose > 0)
+ if (verbose > 0) {
Utils.log.info("Copying unpacked JAR file...");
+ }
Utils.copyJarFile(new JarInputStream(in0), out);
} else if (props.getBoolean(Utils.DEBUG_DISABLE_NATIVE)) {
(new DoUnpack()).run(in0, out);
in0.close();
Utils.markJarFile(out);
@@ -142,18 +144,21 @@
Utils.markJarFile(out);
}
} finally {
_nunp = null;
Utils.currentInstance.set(null);
- if (tz != null) TimeZone.setDefault(tz);
+ if (needUTC) {
+ Utils.restoreDefaultTimeZone();
+ }
}
}
/**
* Takes an input File containing the pack file, and generates a JarOutputStream.
* <p>
* Does not close its output. (The output can accumulate more elements.)
+ *
* @param in a File.
* @param out a JarOutputStream.
* @exception IOException if an error is encountered.
*/
public synchronized void unpack(File in, JarOutputStream out) throws IOException {