Permalink
Browse files

Better program for testing compatibility with lzma(1)

darcs-hash:20090312181456-e5a07-9c97613b063c43eec2fd85f57208b82b16e4eb79.gz
  • Loading branch information...
1 parent 2b488ba commit d1b7080e225b884982077cec88f1d6a677428cf9 @league committed Mar 12, 2009
Showing with 25 additions and 6 deletions.
  1. +25 −6 net/contrapunctus/lzma/LzmaCompat.java
@@ -24,15 +24,34 @@
public class LzmaCompat
{
- public static void main( String[] args ) throws IOException
+ public static void writeFile( String name ) throws IOException
{
- LzmaOutputStream.LZMA_HEADER = args.length > 1;
- System.out.println("LZMA_HEADER = " + LzmaOutputStream.LZMA_HEADER);
- System.out.println("writing " + args[0]);
- FileOutputStream fos = new FileOutputStream(args[0]);
+ System.out.printf("writing %s with%s header\n",
+ name,
+ LzmaOutputStream.LZMA_HEADER? "" : " no");
+ FileOutputStream fos = new FileOutputStream( name );
LzmaOutputStream lo = new LzmaOutputStream( fos );
PrintStream ps = new PrintStream( lo );
- ps.println("Hello, world!");
+ ps.println("Hello, world -- this is a test!");
ps.close(); // is that enough?
}
+
+ public static void main( String[] args ) throws IOException
+ {
+ LzmaOutputStream.LZMA_HEADER = true;
+ writeFile("out-true.txt.lzma");
+ LzmaOutputStream.LZMA_HEADER = false;
+ writeFile("out-false.txt.lzma");
+
+ LzmaOutputStream.LZMA_HEADER = true;
+ FileInputStream fis = new FileInputStream( args[0] );
+ LzmaInputStream li = new LzmaInputStream( fis );
+ InputStreamReader isr = new InputStreamReader( li );
+ BufferedReader br = new BufferedReader( isr );
+ String s;
+ while( null != (s = br.readLine() )) {
+ System.out.println(s);
+ }
+ br.close();
+ }
}

0 comments on commit d1b7080

Please sign in to comment.