Extracting Text from a Binary File

Dr. Andrew Broad
Computer Science
Java
Extracting Text from a Binary File


BinText is a simple Java program for extracting ASCII text from an arbitrary binary file, ignoring control codes. This can be useful for salvaging textual data from a file which no application-program can read, or if a file becomes corrupted and the application can no longer read it.

BinText has a simple command-line interface: its usage is as follows:

java BinText file (start_offset (stop_offset (line_length)))
In other words, each successive argument is optional.

The offsets refer to the range of positions in the file from which you want to extract text (from 0 to one less than the length of the file in bytes). If you don't specify the offsets, it will process the whole file. If you want to specify line_length but not stop_offset, type a negative value such as -1 for stop_offset.

Specifying a line-length causes newlines to be inserted at the end of each line (no word-wrap). For example, to extract text from a file X.BIN with a line-length of 40, you'd use the following command-line:

java BinText X.BIN 0 -1 40

BinText accepts the following command-line flags:


Email me
Hosted by www.Geocities.ws

1