FileDocCategorySizeDatePackage
FileDumper2.javaAPI DocExample1602Mon May 03 14:58:12 BST 1999None

FileDumper2

public class FileDumper2 extends Object

Fields Summary
public static final int
ASC
public static final int
DEC
public static final int
HEX
Constructors Summary
Methods Summary
public static voiddump(java.io.InputStream in, java.io.OutputStream out, int mode)

  
    // The reference variable in may point to several different objects
    // within the space of the next few lines. We can attach
    //  more filters here to do decompression, decryption, and more.
    
    if (mode == ASC) ; // no filter needed, just copy raw bytes
    else if (mode == HEX) in = new HexFilter(in);
    else if (mode == DEC) in = new DecimalFilter(in); 
        
    StreamCopier.copy(in, out);
    in.close();
  
  
public static voidmain(java.lang.String[] args)

  

       

    if (args.length < 1) {
      System.err.println("Usage: java FileDumper2 [-ahd] file1 file2...");
    }

    int firstArg = 0;
    int mode = ASC;

    if (args[0].startsWith("-")) {
      firstArg = 1;
      if (args[0].equals("-h")) mode = HEX;
      else if (args[0].equals("-d")) mode = DEC;
    }

    for (int i = firstArg; i < args.length; i++) {
      try {
        InputStream in = new FileInputStream(args[i]);
        dump(in, System.out, mode);

        if (i < args.length-1) {  // more files to dump
          System.out.println();
          System.out.println("--------------------------------------");
          System.out.println();
        }
        
      }
      catch (IOException e) {
        System.err.println(e);
      }
        
    }