1357 {
1358 byte[] copyBuf = new byte[8192];
1359 int n;
1360 while ((n = is.read(copyBuf)) != -1) {
1361 os.write(copyBuf, 0, n);
1362 }
1363 }
1364
1365 // Returns an out stream for either
1366 // (1) writing the contents of a new entry, if the entry exits, or
1367 // (2) updating/replacing the contents of the specified existing entry.
1368 private OutputStream getOutputStream(Entry e) throws IOException {
1369
1370 if (e.mtime == -1)
1371 e.mtime = System.currentTimeMillis();
1372 if (e.method == -1)
1373 e.method = METHOD_DEFLATED; // TBD: use default method
1374 // store size, compressed size, and crc-32 in LOC header
1375 e.flag = 0;
1376 if (zc.isUTF8())
1377 e.flag |= FLAG_EFS;
1378 OutputStream os;
1379 if (useTempFile) {
1380 e.file = getTempPathForEntry(null);
1381 os = Files.newOutputStream(e.file, WRITE);
1382 } else {
1383 os = new ByteArrayOutputStream((e.size > 0)? (int)e.size : 8192);
1384 }
1385 return new EntryOutputStream(e, os);
1386 }
1387
1388 private InputStream getInputStream(Entry e)
1389 throws IOException
1390 {
1391 InputStream eis = null;
1392
1393 if (e.type == Entry.NEW) {
1394 if (e.bytes != null)
1395 eis = new ByteArrayInputStream(e.bytes);
1396 else if (e.file != null)
1397 eis = Files.newInputStream(e.file);
|
1357 {
1358 byte[] copyBuf = new byte[8192];
1359 int n;
1360 while ((n = is.read(copyBuf)) != -1) {
1361 os.write(copyBuf, 0, n);
1362 }
1363 }
1364
1365 // Returns an out stream for either
1366 // (1) writing the contents of a new entry, if the entry exits, or
1367 // (2) updating/replacing the contents of the specified existing entry.
1368 private OutputStream getOutputStream(Entry e) throws IOException {
1369
1370 if (e.mtime == -1)
1371 e.mtime = System.currentTimeMillis();
1372 if (e.method == -1)
1373 e.method = METHOD_DEFLATED; // TBD: use default method
1374 // store size, compressed size, and crc-32 in LOC header
1375 e.flag = 0;
1376 if (zc.isUTF8())
1377 e.flag |= FLAG_USE_UTF8;
1378 OutputStream os;
1379 if (useTempFile) {
1380 e.file = getTempPathForEntry(null);
1381 os = Files.newOutputStream(e.file, WRITE);
1382 } else {
1383 os = new ByteArrayOutputStream((e.size > 0)? (int)e.size : 8192);
1384 }
1385 return new EntryOutputStream(e, os);
1386 }
1387
1388 private InputStream getInputStream(Entry e)
1389 throws IOException
1390 {
1391 InputStream eis = null;
1392
1393 if (e.type == Entry.NEW) {
1394 if (e.bytes != null)
1395 eis = new ByteArrayInputStream(e.bytes);
1396 else if (e.file != null)
1397 eis = Files.newInputStream(e.file);
|