Class Shredder2

java.lang.Object
mgui.neuro.imaging.camino.tasks.Shredder2

public class Shredder2
extends java.lang.Object
Extracts periodic chunks from binary data. Call with command line:

java apps.Shredder <offset &rt < chunkSize &rt < space &rt

Shredder makes an initial offset of offset bytes. It then reads and outputs chunkSize bytes, skips space bytes, and repeats until there is no more input.

If the chunkSize is negative, chunks of size |chunkSize| are read and the byte ordering of each chunk is reversed. If byte swapping is required, the chunkSize should correspond to the size of the data type.

Version:
$Id: Shredder.java 445 2007-12-05 18:12:05Z ucacpco $
Author:
Danny Alexander, Philip Cook
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int FILEBUFFERSIZE  
    static java.io.InputStream in  
    static java.io.OutputStream out  
  • Constructor Summary

    Constructors
    Constructor Description
    Shredder2()  
  • Method Summary

    Modifier and Type Method Description
    static void arrFlip​(byte[] chunk)
    Reverses the order of the bytes in the array.
    static boolean getChunk​(byte[] chunk)
    Reads in the next chunk from the standard input into the array chunk and returns a boolean indicating the success of the operation.
    static void main​(java.lang.String[] args)  
    static void output​(byte[] chunk)
    Outputs the chunk to the standard output.
    static boolean skip​(int bytesToSkip)
    Skip bytes from the input stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FILEBUFFERSIZE

      public static int FILEBUFFERSIZE
    • in

      public static java.io.InputStream in
    • out

      public static java.io.OutputStream out
  • Constructor Details

    • Shredder2

      public Shredder2()
  • Method Details

    • main

      public static void main​(java.lang.String[] args)
    • getChunk

      public static boolean getChunk​(byte[] chunk)
      Reads in the next chunk from the standard input into the array chunk and returns a boolean indicating the success of the operation.
      Parameters:
      chunk - An array to contain the chunks
      Returns:
      boolean indicating whether or not the chunk was read successfully. If part of a chunk was read successfully, the return value is true. Note that if only part of a chunk is read, the remaining bytes will contain the original contents of chunk
    • skip

      public static boolean skip​(int bytesToSkip)
      Skip bytes from the input stream.
      Parameters:
      bytesToSkip - the number of bytes to skip.
      Returns:
      true if the bytes were skipped successfully, false if EOF was found before enough bytes could be skipped.
    • output

      public static void output​(byte[] chunk)
      Outputs the chunk to the standard output.
      Parameters:
      chunk - The chunk to output.
    • arrFlip

      public static void arrFlip​(byte[] chunk)
      Reverses the order of the bytes in the array.
      Parameters:
      The - chunk to reverse.