Examples of ZipEntry


Examples of java.util.zip.ZipEntry

    public InputStream getInputStream() throws IOException {
        ZipFile zipfile = null;
        try {
            zipfile = repository.getZipFile();
            ZipEntry entry = zipfile.getEntry(entryName);
            if (entry == null) {
                throw new IOException("Zip resource " + this + " does not exist");
            }
            int size = (int) entry.getSize();
            byte[] buf = new byte[size];
            InputStream in = zipfile.getInputStream(entry);
            int read = 0;
            while (read < size) {
                int r = in.read(buf, read, size-read);
View Full Code Here

Examples of java.util.zip.ZipEntry

    public String getContent(String encoding) throws IOException {
        ZipFile zipfile = null;
        try {
            zipfile = repository.getZipFile();
            ZipEntry entry = zipfile.getEntry(entryName);
            if (entry == null) {
                throw new IOException("Zip resource " + this + " does not exist");
            }
            InputStream in = zipfile.getInputStream(entry);
            int size = (int) entry.getSize();
            byte[] buf = new byte[size];
            int read = 0;
            while (read < size) {
                int r = in.read(buf, read, size-read);
                if (r == -1)
View Full Code Here

Examples of java.util.zip.ZipEntry

  /**
   * Returns the size of the file or 0 if it does not exist.
   */
  public long size()
  {
    ZipEntry entry ;
   
    try
    {
      if ( this.isInArchive() )
      {
        entry = this.archiveEntry() ;
        // if ( DEBUG ) com.mdcs.joi.Inspector.inspectWait( entry ) ;
        return entry.getSize() ;
      }
      else
      {
        return this.getFile().length() ;
      }
View Full Code Here

Examples of java.util.zip.ZipEntry

   * Returns the timestamp of when the file was last modified
   * or 0 in any case of error.
   */
  public long lastModified()
  {
    ZipEntry entry ;
   
    try
    {
      if ( this.isInArchive() )
      {
        entry = this.archiveEntry() ;
        return entry.getTime() ;
      }
      else
      {
        return this.getFile().lastModified() ;
      }
View Full Code Here

Examples of java.util.zip.ZipEntry

   * Returns an opened input stream on the file defined by this locator.
   */
  public InputStream getInputStream()
    throws Exception
  {
    ZipEntry entry ;
   
    if ( this.isInArchive() )
    {
      entry = this.archiveEntry() ;
      return this.container().getInputStream( entry ) ;
View Full Code Here

Examples of java.util.zip.ZipEntry

  // -------------------------------------------------------------------------

  protected boolean doesElementExistInArchive( String elementName )
    throws Exception
  {
    ZipEntry entry ;

    entry = this.entryFromArchive( elementName ) ;
       
    return ( entry != null ) ;
  } // doesElementExistInArchive()
View Full Code Here

Examples of java.util.zip.ZipEntry

  // -------------------------------------------------------------------------

  protected boolean isFileInArchive( String elementName )
    throws Exception
  {
    ZipEntry entry ;
    entry = this.entryFromArchive( elementName ) ;
   
    // Unfortunately entry.isDirectory() returns false even for
    // pure directory entries inside a zip archive, so it can't be used here.
    // The trick below is problematic, because apart from
    // directories it will also not recognize files with size 0.
   
    return ( entry != null ) && ( entry.getSize() > 0 ) ;
  } // isFileInArchive()
View Full Code Here

Examples of java.util.zip.ZipEntry

  // -------------------------------------------------------------------------

  protected ZipEntry entryFromArchive( String elementName )
    throws Exception
  {
    ZipEntry entry ;
    ZipFile archive ;
    String name ;
   
    name = str().replaceAll( elementName, "\\", "/" ) ;
    archive = this.container() ;
    entry = archive.getEntry( name ) ;

    if (DEBUG)
    {
      // if ( entry == null ) com.mdcs.joi.Inspector.inspect( name ) ;
      System.out.print( archive.getName() + "::" + name + " --- "
                + ( entry != null ) ) ;
      if ( entry == null )
      {
        System.out.println() ;       
      }
      else
      {
        System.out.print( " (" + entry.getSize()  + ")" ) ;
        System.out.print( " (T:" + entry.getTime()  + ")" ) ;
        System.out.println( " (" + ( entry.isDirectory() ? "Dir" : "File" ) + ")" ) ;
      }
    }
   
    return entry ;
  } // entryFromArchive()
View Full Code Here

Examples of java.util.zip.ZipEntry

  protected File fileRef()
    throws Exception
  {
    InputStream archiveStream ;
    FileOutputStream fileStream ;
    ZipEntry entry ;
    File tempFile ;
   
    if ( this.isInArchive() )
    {
      entry = this.archiveEntry() ;
View Full Code Here

Examples of java.util.zip.ZipEntry

        zipFile = new ZipFile(file);
       
        entries = zipFile.entries();

        while(entries.hasMoreElements()) {
          ZipEntry entry = (ZipEntry)entries.nextElement();
          if(entry.isDirectory()) {
            (new File(targetDir, entry.getName())).mkdir();
            continue;
          }
          InputStream in = zipFile.getInputStream(entry);
          OutputStream out = new FileOutputStream(new File(targetDir, entry.getName()));   
          try {
            WGUtils.inToOut(in, out, 2048);
          } finally {
            out.close();
            in.close();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.