import java.io.FilterInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Random; public class Unscramble{ public static void main(String[] args){ if(args.length!=2){ System.err.println("usage: java Unscramble srcpath destpath"); return; } UnscrambleInputStream uis = null; FileOutputStream fos = null; try{ FileInputStream fis = new FileInputStream(args[0]); uis = new UnscrambleInputStream(fis, makeMap()); fos = new FileOutputStream(args[1]); /*int b; while((b=uis.read())!=-1){ fos.write(b); } */ // test the byte[] read method byte[] bytes = new byte[128]; int readLength; while((readLength= uis.read(bytes, 0, bytes.length))!=-1){ fos.write(bytes, 0, readLength); } }catch(IOException ioe){ ioe.printStackTrace(); }finally{ if(uis!=null){ try{ uis.close(); }catch(IOException ioe){ ioe.printStackTrace(); } } if(fos!=null){ try{ fos.close(); }catch(IOException ioe){ ioe.printStackTrace(); } } } } static int[] makeMap(){ int[] map = new int[256]; for(int i=0;i