Java Doc for CBZip2OutputStream.java in  » Build » ANT » org » apache » tools » bzip2 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.bzip2 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.OutputStream
      org.apache.tools.bzip2.CBZip2OutputStream

CBZip2OutputStream
public class CBZip2OutputStream extends OutputStream implements BZip2Constants(Code)
An output stream that compresses into the BZip2 format (without the file header chars) into another stream.

The compression requires large amounts of memory. Thus you should call the CBZip2OutputStream.close() close() method as soon as possible, to force CBZip2OutputStream to release the allocated memory.

You can shrink the amount of allocated memory and maybe raise the compression speed by choosing a lower blocksize, which in turn may cause a lower compression ratio. You can avoid unnecessary memory allocation by avoiding using a blocksize which is bigger than the size of the input.

You can compute the memory usage for compressing by the following formula:

 400k + (9 * blocksize).
 

To get the memory required for decompression by CBZip2InputStream CBZip2InputStream use

 65k + (5 * blocksize).
 
Memory usage by blocksize
Blocksize Compression
memory usage
Decompression
memory usage
100k 1300k 565k
200k 2200k 1065k
300k 3100k 1565k
400k 4000k 2065k
500k 4900k 2565k
600k 5800k 3065k
700k 6700k 3565k
800k 7600k 4065k
900k 8500k 4565k

For decompression CBZip2InputStream allocates less memory if the bzipped input is smaller than one block.

Instances of this class are not threadsafe.

TODO: Update to BZip2 1.0.1



Field Summary
final protected static  intCLEARMASK
     This constant is accessible by subclasses for historical purposes.
final protected static  intDEPTH_THRESH
     This constant is accessible by subclasses for historical purposes.
final protected static  intGREATER_ICOST
     This constant is accessible by subclasses for historical purposes.
final protected static  intLESSER_ICOST
     This constant is accessible by subclasses for historical purposes.
final public static  intMAX_BLOCKSIZE
     The maximum supported blocksize == 9.
final public static  intMIN_BLOCKSIZE
     The minimum supported blocksize == 1.
final protected static  intQSORT_STACK_SIZE
     This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.

If you are ever unlucky/improbable enough to get a stack overflow whilst sorting, increase the following constant and try again.

final protected static  intSETMASK
     This constant is accessible by subclasses for historical purposes.
final protected static  intSMALL_THRESH
     This constant is accessible by subclasses for historical purposes.
final protected static  intWORK_FACTOR
     This constant is accessible by subclasses for historical purposes.

Constructor Summary
public  CBZip2OutputStream(OutputStream out)
     Constructs a new CBZip2OutputStream with a blocksize of 900k.
public  CBZip2OutputStream(OutputStream out, int blockSize)
     Constructs a new CBZip2OutputStream with specified blocksize.

Method Summary
public static  intchooseBlockSize(long inputLength)
     Chooses a blocksize based on the given length of the data to compress. The blocksize, between CBZip2OutputStream.MIN_BLOCKSIZE and CBZip2OutputStream.MAX_BLOCKSIZEboth inclusive.
public  voidclose()
    
protected  voidfinalize()
     Overriden to close the stream.
public  voidflush()
    
final public  intgetBlockSize()
     Returns the blocksize parameter specified at construction time.
protected static  voidhbMakeCodeLengths(char[] len, int[] freq, int alphaSize, int maxLen)
     This method is accessible by subclasses for historical purposes.
public  voidwrite(int b)
    
public  voidwrite(byte[] buf, int offs, int len)
    

Field Detail
CLEARMASK
final protected static int CLEARMASK(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.



DEPTH_THRESH
final protected static int DEPTH_THRESH(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.



GREATER_ICOST
final protected static int GREATER_ICOST(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.



LESSER_ICOST
final protected static int LESSER_ICOST(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.



MAX_BLOCKSIZE
final public static int MAX_BLOCKSIZE(Code)
The maximum supported blocksize == 9.



MIN_BLOCKSIZE
final public static int MIN_BLOCKSIZE(Code)
The minimum supported blocksize == 1.



QSORT_STACK_SIZE
final protected static int QSORT_STACK_SIZE(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.

If you are ever unlucky/improbable enough to get a stack overflow whilst sorting, increase the following constant and try again. In practice I have never seen the stack go above 27 elems, so the following limit seems very generous.




SETMASK
final protected static int SETMASK(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.



SMALL_THRESH
final protected static int SMALL_THRESH(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.



WORK_FACTOR
final protected static int WORK_FACTOR(Code)
This constant is accessible by subclasses for historical purposes. If you don't know what it means then you don't need it.




Constructor Detail
CBZip2OutputStream
public CBZip2OutputStream(OutputStream out) throws IOException(Code)
Constructs a new CBZip2OutputStream with a blocksize of 900k.

Attention: The caller is resonsible to write the two BZip2 magic bytes "BZ" to the specified stream prior to calling this constructor.


Parameters:
  out - * the destination stream.
throws:
  IOException - if an I/O error occurs in the specified stream.
throws:
  NullPointerException - if out == null.



CBZip2OutputStream
public CBZip2OutputStream(OutputStream out, int blockSize) throws IOException(Code)
Constructs a new CBZip2OutputStream with specified blocksize.

Attention: The caller is resonsible to write the two BZip2 magic bytes "BZ" to the specified stream prior to calling this constructor.


Parameters:
  out - the destination stream.
Parameters:
  blockSize - the blockSize as 100k units.
throws:
  IOException - if an I/O error occurs in the specified stream.
throws:
  IllegalArgumentException - if (blockSize < 1) || (blockSize > 9).
throws:
  NullPointerException - if out == null.
See Also:   CBZip2OutputStream.MIN_BLOCKSIZE
See Also:   CBZip2OutputStream.MAX_BLOCKSIZE




Method Detail
chooseBlockSize
public static int chooseBlockSize(long inputLength)(Code)
Chooses a blocksize based on the given length of the data to compress. The blocksize, between CBZip2OutputStream.MIN_BLOCKSIZE and CBZip2OutputStream.MAX_BLOCKSIZEboth inclusive. For a negative inputLength this method returnsMAX_BLOCKSIZE always.
Parameters:
  inputLength - The length of the data which will be compressed byCBZip2OutputStream.



close
public void close() throws IOException(Code)



finalize
protected void finalize() throws Throwable(Code)
Overriden to close the stream.



flush
public void flush() throws IOException(Code)



getBlockSize
final public int getBlockSize()(Code)
Returns the blocksize parameter specified at construction time.



hbMakeCodeLengths
protected static void hbMakeCodeLengths(char[] len, int[] freq, int alphaSize, int maxLen)(Code)
This method is accessible by subclasses for historical purposes. If you don't know what it does then you don't need it.



write
public void write(int b) throws IOException(Code)



write
public void write(byte[] buf, int offs, int len) throws IOException(Code)



Methods inherited from java.io.OutputStream
public void close() throws IOException(Code)(Java Doc)
public void flush() throws IOException(Code)(Java Doc)
abstract public void write(int b) throws IOException(Code)(Java Doc)
public void write(byte b) throws IOException(Code)(Java Doc)
public void write(byte b, int off, int len) throws IOException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.