donaldp 02/03/24 01:06:35
Modified: bzip2/examples README.txt
Added: bzip2/examples/basic Bzip2Compress.java Bzip2Uncompress.java
README.txt
Log:
Add some examples for Bzip
Revision Changes Path
1.2 +6 -0 jakarta-avalon-excalibur/bzip2/examples/README.txt
Index: README.txt
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/bzip2/examples/README.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- README.txt 24 Mar 2002 07:02:31 -0000 1.1
+++ README.txt 24 Mar 2002 09:06:35 -0000 1.2
@@ -1,2 +1,8 @@
This directory contains a number of examples for the component.
They are;
+
+basic
+-----
+This simple example shows how to use the Bzip2 classes to compress and
+uncompress a file. If the file is a bzip2 archive it will uncompress
+else it will compress the file.
\ No newline at end of file
1.1
jakarta-avalon-excalibur/bzip2/examples/basic/Bzip2Compress.java
Index: Bzip2Compress.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.avalon.excalibur.bzip2.CBZip2OutputStream;
/**
* This simple example shows how to use the Bzip2 classes to compress a file.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/03/24 09:06:35 $
*/
public class Bzip2Compress
{
public static void main( final String[] args )
throws Exception
{
if( 2 != args.length )
{
System.out.println( "java Bzip2Compress <input> <output>" );
System.exit( 1 );
}
final File source = new File( args[ 0 ] );
final File destination = new File( args[ 1 ] );
final CBZip2OutputStream output =
new CBZip2OutputStream( new FileOutputStream( destination ) );
final FileInputStream input = new FileInputStream( source );
copy( input, output );
input.close();
output.close();
}
/**
* Copy bytes from an <code>InputStream</code> to an
<code>OutputStream</code>.
*/
private static void copy( final InputStream input,
final OutputStream output )
throws IOException
{
final byte[] buffer = new byte[ 8024 ];
int n = 0;
while( -1 != ( n = input.read( buffer ) ) )
{
output.write( buffer, 0, n );
}
}
}
1.1
jakarta-avalon-excalibur/bzip2/examples/basic/Bzip2Uncompress.java
Index: Bzip2Uncompress.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.avalon.excalibur.bzip2.CBZip2InputStream;
/**
* This simple example shows how to use the Bzip2 classes to uncompress a
file.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/03/24 09:06:35 $
*/
public class Bzip2Uncompress
{
public static void main( final String[] args )
{
if( 2 != args.length )
{
System.out.println( "java Bzip2Uncompress <input> <output>" );
System.exit( 1 );
}
final File source = new File( args[ 0 ] );
final File destination = new File( args[ 1 ] );
final FileOutputStream output =
new FileOutputStream( destination );
final CBZip2InputStream input = new CBZip2InputStream( new
FileInputStream( source ) );
copy( input, output );
input.close();
output.close();
}
/**
* Copy bytes from an <code>InputStream</code> to an
<code>OutputStream</code>.
*/
private static void copy( final InputStream input,
final OutputStream output )
throws IOException
{
final byte[] buffer = new byte[ 8024 ];
int n = 0;
while( -1 != ( n = input.read( buffer ) ) )
{
output.write( buffer, 0, n );
}
}
}
1.1 jakarta-avalon-excalibur/bzip2/examples/basic/README.txt
Index: README.txt
===================================================================
Welcome to Excalibur Bzip2!
As always, the if you have any questions :
1) Make sure you followed any directions
2) Review documentation included in this package, or online at
http://jakarta.apache.org/avalon/excalibur
3) Ask on the avalon-dev list. This is a great source of support
information. To join, read http://jakarta.apache.org/site/mail.html
and then follow the link at the bottom to join the lists.
basic
-----
This simple example shows how to use the Bzip2 classes to compress and
uncompress a file. If the file is a bzip2 archive it will uncompress
else it will compress the file.
Compile it by running
javac -classpath ../../build/lib/@[EMAIL PROTECTED] *.java (Unix)
or
javac -classpath [EMAIL PROTECTED]@.jar *.java (Windows)
Run it using the following to compress:
java -classpath ../../build/lib/@[EMAIL PROTECTED]:. Bzip2Compress
README.txt README.txt.bz2 (Unix)
or
java -classpath [EMAIL PROTECTED]@.jar;. Bzip2Compress README.txt
README.txt.bz2 (Windows)
And the following to uncompress:
java -classpath ../../build/lib/@[EMAIL PROTECTED]:. Bzip2Uncompress
README.txt.bz2 README.txt (Unix)
or
java -classpath [EMAIL PROTECTED]@.jar;. Bzip2Uncompress README.txt.bz2
README.txt (Windows)
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>