1 19 20 package edu.umd.cs.findbugs.ba; 21 22 import java.io.FileNotFoundException ; 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 import java.util.zip.ZipEntry ; 26 import java.util.zip.ZipFile ; 27 28 32 public class ZipSourceFileDataSource implements SourceFileDataSource { 33 private ZipFile zipFile; 34 private String entryName; 35 private ZipEntry zipEntry; 36 37 public ZipSourceFileDataSource(ZipFile zipFile, String entryName) { 38 this.zipFile = zipFile; 39 this.entryName = entryName; 40 this.zipEntry = zipFile.getEntry(entryName); 41 } 42 43 public InputStream open() throws IOException { 44 if (zipEntry == null) 45 throw new FileNotFoundException ("No zip entry for " + entryName); 46 return zipFile.getInputStream(zipEntry); 47 } 48 49 public String getFullFileName() { 50 return entryName; 51 } 52 } 53 54 | Popular Tags |