KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > util > jar > JarOutputStream

java.util.jar
Class JarOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.util.zip.DeflaterOutputStream
              extended by java.util.zip.ZipOutputStream
                  extended by java.util.jar.JarOutputStream
All Implemented Interfaces:
Closeable, Flushable
See Also:
Top Examples, Source Code, Manifest

public static final int CENATT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENATX
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENCOM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENCRC
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENDSK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENEXT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENFLG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENHDR
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENHOW
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENLEN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENNAM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENOFF
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final long CENSIG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENSIZ
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENTIM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENVEM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CENVER
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ENDCOM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ENDHDR
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ENDOFF
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final long ENDSIG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ENDSIZ
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ENDSUB
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ENDTOT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int EXTCRC
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int EXTHDR
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int EXTLEN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final long EXTSIG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int EXTSIZ
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JarOutputStream(OutputStream out)
                throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1043]Read file and write it to the jar
By Anonymous on 2005/02/01 08:41:54  Rate
    String [  ]  xmits = new String [ 1 ] ; 
     xmits [ 0 ]  = "xmit.jar"; 
     JarOutputStream jar = new JarOutputStream (  
         new FileOutputStream ( scannerDir + "/jar/" + xmits [ 0 ]  ) , new Manifest (  )  ) ; 
  
  
     byte [  ]  buffer = new byte [ 1024 ] ; 
     int count; 
  
  
     for  ( int i = 1; i  <  files.length; i++ )   {  
       InputStream is = new BufferedInputStream (  new FileInputStream ( scannerDir + "/" + files [ i ]  )  ) ; 
       JarEntry entry = new JarEntry ( files [ i ]  ) ; 
       jar.putNextEntry ( entry ) ; 
  
  
       // Read the file the file and write it to the jar. 
       while  (  ( count = is.read ( buffer )  )  != -1 )   {  
         jar.write ( buffer, 0, count ) ; 
        }  
      }  
     jar.close (  ) ;


public JarOutputStream(OutputStream out,
                       Manifest man)
                throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCCRC
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCEXT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCFLG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCHDR
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCHOW
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCLEN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCNAM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final long LOCSIG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCSIZ
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCTIM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LOCVER
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void putNextEntry(ZipEntry ze)
                  throws IOException
See Also:
ZipException, ZipOutputStream
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[129]Copy files from one JAR to another JAR
By Milton on 2005/02/01 08:42:20  Rate
JarOutputStream jarOut = new JarOutputStream ( new FileOutputStream (  filename  ) , 
                                                  manifest ) ; 
  
  
  
 We must write every entry from the input JAR to the output JAR, so iterate over the entries: 
  
  
  
     //Create a read buffer to transfer data from the input 
  
  
     byte [  ]  buf = new byte [ 4096 ] ; 
  
  
     //Iterate the entries 
  
  
     JarEntry entry; 
     while  (  ( entry = jarIn.getNextJarEntry (  )  )  != null )   {  
         //Exclude the manifest file from the old JAR 
  
  
         if  ( "META-INF/MANIFEST.MF".equals ( entry.getName (  )  )  )  continue; 
  
  
         //Write the entry to the output JAR 
  
  
         jarOut.putNextEntry ( entry ) ; 
         int read; 
         while  (  ( read = jarIn.read ( buf )  )  != -1 )   {  
             jarOut.write ( buf, 0, read ) ; 
          }  
  
  
         jarOut.closeEntry (  ) ; 
      }  
  
  
     //Flush and close all the streams 
  
  
     jarOut.flush (  ) ; 
     jarOut.close (  ) ; 
  
  
  
  
 

Popular Tags