ZipFile getInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ZipFile getInputStream method.

This code example shows how to use the following methods:getEntry, getInputStream
	} 
 
	public InputStream openStream() throws IOException {
		// 注:ZipFile与File的设计是不一样的,File相当于C#的FileInfo,只持有信息, 
		// 而ZipFile构造时即打开流,所以每次读取数据时,重新new新的实例,而不作为属性字段持有。 
		ZipFile zipFile = new ZipFile(file);
		return zipFile.getInputStream(zipFile.getEntry(getName()));
	} 
 
	public long getLastModified() { 
		return file.lastModified();
	} 
 
	public long getLength() { 
		try { 
			ZipFile zipFile = new ZipFile(file);
			try { 
				return zipFile.getEntry(getName()).getSize();
			} finally { 
				zipFile.close();
7
CodeRank
This code example shows how to use the following methods:entries, getInputStream, size
        } 
        return createZIPInputStream(file);
    } 
 
    private static InputStream createZIPInputStream(File file) throws IOException {
        final ZipFile productZip = new ZipFile(file, ZipFile.OPEN_READ);
        if (productZip.size() != 1) {
            throw new IllegalFileFormatException("Illegal ZIP format, single file entry expected."); 
        } 
        final Enumeration<? extends ZipEntry> entries = productZip.entries();
        final ZipEntry zipEntry = entries.nextElement();
        if (zipEntry == null || zipEntry.isDirectory()) {
            throw new IllegalFileFormatException("Illegal ZIP format, single file entry expected."); 
        } 
        return productZip.getInputStream(zipEntry);
    } 
 
    private static InputStream createGZIPInputStream(File file) throws IOException {
        return new GZIPInputStream(new FileInputStream(file));
    } 
7
CodeRank
This code example shows how to use the following methods:close, getEntry, getInputStream
This code example shows how to use the following methods:getInputStream
    } 
 
    @Override 
    public InputStream getInput() throws IOException
    { 
        return zipFile.getInputStream(zipEntry);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:close, getEntry, getInputStream
	 * @param filePathinZip - path for file in zip 
	 * @param tagSet - the morpheme tag set used in the rules 
	 * @throws IOException 
	 */ 
	public void init(String zipFilePath, String filePathinZip, TagSet tagSet)throws IOException  {
		ZipFile zip = new ZipFile(zipFilePath);
		ZipEntry entry = zip.getEntry(filePathinZip);
		InputStream in  = zip.getInputStream(entry);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		readFile(br,tagSet);
		zip.close();
	} 
	 
	/** 
	 * Reads the impossible connection rules from the specified file. 
	 * @param br - the BufferedReader for the impossible connection rules 
	 * @param tagSet - the morpheme tag set used in the rules 
	 * @throws IOException 
	 */ 
	private void readFile(BufferedReader br, TagSet tagSet) throws IOException {
6
CodeRank
This code example shows how to use the following methods:close, getEntry, getInputStream
  } 
   
  /** Run a vocabulary test against a tab-separated data file inside a zip file */ 
  public static void assertVocabulary(Analyzer a, File zipFile, String vocOut)
  throws IOException { 
    ZipFile zip = new ZipFile(zipFile);
    InputStream vo = zip.getInputStream(zip.getEntry(vocOut));
    assertVocabulary(a, vo);
    vo.close();
    zip.close();
  } 
} 
6
CodeRank
This code example shows how to use the following methods:getEntry, getInputStream
		} 
		return nativeFile.exists() ? nativeFile.getAbsolutePath() : null;
	} 
 
	private InputStream getFromJar (String jarFile, String sharedLibrary) throws IOException {
		ZipFile file = new ZipFile(nativesJar);
		ZipEntry entry = file.getEntry(sharedLibrary);
		return file.getInputStream(entry);
	} 
 
	/** Loads a shared library with the given name for the platform the application is running on. The name should not contain a 
	 * prefix (e.g. 'lib') or suffix (e.g. '.dll). 
	 * @param sharedLibName */ 
	public synchronized void load (String sharedLibName) {
		if (loadedLibraries.contains(sharedLibName)) return;
 
		boolean isWindows = System.getProperty("os.name").contains("Windows");
		boolean isLinux = System.getProperty("os.name").contains("Linux");
		boolean isMac = System.getProperty("os.name").contains("Mac");
		boolean isAndroid = false;
7
CodeRank
This code example shows how to use the following methods:getEntry, getInputStream
        this.entry = entry;
    } 
 
    @Override 
    public InputStream getStream() throws IOException {
        ZipFile zf = new ZipFile(file);
        ZipEntry zentry = zf.getEntry(entry);
        if (zentry == null) {
            return null; 
        } 
        return new ZipEntryInputStream(zf, zf.getInputStream(zentry));
    } 
 
    @Override 
    public boolean canReopen() { 
        return true; 
    } 
 
    @Override 
    public long getLength() throws IOException { 
6
CodeRank
This code example shows how to use the following methods:getEntry, getInputStream
			return input;
		} 
 
		// Read from JAR. 
		try { 
			ZipFile file = new ZipFile(nativesJar);
			ZipEntry entry = file.getEntry(path);
			if (entry == null) throw new GdxRuntimeException("Couldn't find '" + path + "' in JAR: " + nativesJar);
			return file.getInputStream(entry);
		} catch (IOException ex) {
			throw new GdxRuntimeException("Error reading '" + path + "' in JAR: " + nativesJar, ex);
		} 
	} 
 
	/** Extracts the specified file into the temp directory if it does not already exist or the CRC does not match. If file 
	 * extraction fails and the file exists at java.library.path, that file is returned. 
	 * @param sourcePath The file to extract from the classpath or JAR. 
	 * @param dirName The name of the subdirectory where the file will be extracted. If null, the file's CRC will be used. 
	 * @return The extracted file. */ 
	public File extractFile (String sourcePath, String dirName) throws IOException {
7
CodeRank
This code example shows how to use the following methods:close, getEntry, getInputStream
	 * @param tagCount - the number of the total tags 
	 * @param tagSet - the tag set which is used in the connection rules 
	 * @throws IOException 
	 */ 
	public void init(String zipFilePath, String filePathinZip, int tagCount, TagSet tagSet ) throws IOException {
		ZipFile zip = new ZipFile(zipFilePath);
		ZipEntry entry = zip.getEntry(filePathinZip);
		InputStream in  = zip.getInputStream(entry);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		readFile(br, tagCount, tagSet);
		zip.close();
	} 
	 
	/** 
	 * Reads the connection rule data file, and initialize the object. 
	 * @param br - the BufferedReader for the connection rule file 
	 * @param tagCount - the number of total tags in the tag set 
	 * @param tagSet - the tag set which is used in the connection rules 
	 * @throws IOException 
	 */ 
6
CodeRank

Related ZipFile getInputStream Questions & Answers:

getInputStream Method Overview
Returns an input stream for reading the contents of the specified zip file entry.
See Code Examples for other Java 8 ZipFile Methods: