public class Shredder extends Executable
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.
Modifier and Type | Field and Description |
---|---|
static int |
FILEBUFFERSIZE |
static java.io.DataInputStream |
in |
static java.io.DataOutputStream |
out |
Constructor and Description |
---|
Shredder(java.lang.String[] args) |
Modifier and Type | Method and Description |
---|---|
static void |
arrFlip(byte[] chunk)
Reverses the order of the bytes in the array.
|
void |
execute(OutputManager om)
abstract method execution for commands
|
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.
|
void |
initDefaultVals()
initialise the default values of class-level
fields, as they would be at declaration.
|
void |
initOptions(java.lang.String[] args)
default commandline parsing and initialisation
|
void |
initVariables()
abstract initialisation method for commands
|
static void |
output(byte[] chunk)
Outputs the chunk to the standard output.
|
static boolean |
skip(int bytesToSkip)
Skip bytes from the input stream.
|
public static int FILEBUFFERSIZE
public static java.io.DataInputStream in
public static java.io.DataOutputStream out
public void initDefaultVals()
Executable
initDefaultVals
in class Executable
public void initOptions(java.lang.String[] args)
Executable
initOptions
in class Executable
public void initVariables()
Executable
initVariables
in class Executable
public void execute(OutputManager om)
Executable
execute
in class Executable
public static boolean getChunk(byte[] chunk)
chunk
- An array to contain the chunkstrue
.
Note that if only part of a chunk is read, the remaining bytes will contain the original
contents of chunk
public static boolean skip(int bytesToSkip)
bytesToSkip
- the number of bytes to skip.true
if the bytes were skipped successfully, false
if EOF was found
before enough bytes could be skipped.public static void output(byte[] chunk)
chunk
- The chunk to output.public static void arrFlip(byte[] chunk)
The
- chunk to reverse.