Changeset 2889 in josm for trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
- Timestamp:
- 24.01.2010 14:20:12 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
r2832 r2889 13 13 import java.net.URL; 14 14 import java.net.URLConnection; 15 import java.util.Enumeration; 16 import java.util.zip.ZipEntry; 17 import java.util.zip.ZipFile; 15 18 16 19 import org.openstreetmap.josm.Main; … … 62 65 throw new IOException(); 63 66 fs = new FileInputStream(file); 67 } 68 69 public InputStream getZipEntry(String extension, String namepart) 70 { 71 InputStream res = null; 72 try { 73 if(file != null && (file.getName().endsWith(".zip") 74 || file.getName().endsWith(".ZIP"))) 75 { 76 ZipFile zipFile = new ZipFile(file); 77 ZipEntry resentry = null; 78 Enumeration entries = zipFile.entries(); 79 while(entries.hasMoreElements()) { 80 ZipEntry entry = (ZipEntry)entries.nextElement(); 81 if(entry.getName().endsWith("."+extension)) { 82 /* choose any file with correct extension. When more than 83 one file, prefer the one which matches namepart */ 84 if(resentry == null || entry.getName().indexOf(namepart) >= 0) { 85 resentry = entry; 86 } 87 } 88 } 89 if(resentry != null) { 90 res = zipFile.getInputStream(resentry); 91 } 92 else { 93 zipFile.close(); 94 } 95 } 96 } catch (Exception e) { 97 System.err.println(tr("Warning: failed to handle zip file ''{0}''. Exception was: {1}", file.getName(), e.toString())); 98 } 99 return res; 64 100 } 65 101
Note: See TracChangeset
for help on using the changeset viewer.
