Changeset 10010 for trunk/gli/src/org/greenstone/gatherer/util
- Timestamp:
- 2005-06-03T14:57:34+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r10009 r10010 471 471 472 472 473 static public boolean isInJar(String filename)474 {475 try {476 InputStream fis = base.getResourceAsStream("/"+filename);477 478 fis.close();479 480 }481 catch (Exception error) {482 System.err.println("**** collect.zip not there!");483 error.printStackTrace();484 485 486 return false;487 }488 return true;489 }490 491 492 493 static public void extractFromJar(String filename, String dst_dir, boolean must_be_present)494 {495 try {496 // setup input stream for slurping out file497 InputStream fis = base.getResourceAsStream("/"+filename);498 BufferedInputStream fbis = new BufferedInputStream(fis);499 DataInputStream fdbis = new DataInputStream(fbis);500 501 // set up output stream for writing to disk502 String ofname = dst_dir + filename;503 FileOutputStream fos = new FileOutputStream(ofname);504 BufferedOutputStream bfos = new BufferedOutputStream(fos);505 506 byte[] buf = new byte[1024];507 int len;508 int total_bytes = 0;509 while ((len = fdbis.read(buf)) >= 0) {510 bfos.write(buf,0,len);511 total_bytes += len;512 }513 514 fdbis.close();515 bfos.close();516 }517 catch (Exception error) {518 if (must_be_present) {519 error.printStackTrace();520 }521 }522 }523 524 525 473 /** Method which unzips a given metadata resoure 526 474 * @param zip_fname The name of the zip file as a <strong>String</strong>. … … 535 483 } 536 484 537 extractFromJar(jar_zip_fname,dst_dir,true);485 JarTools.extractFromJar(jar_zip_fname,dst_dir,true); 538 486 539 487 String zip_ofname = dst_dir + jar_zip_fname;
Note:
See TracChangeset
for help on using the changeset viewer.