File I/O Lab
Write a Binary File Viewer
that can display the contents of a file in binary. Your program will
feature
- a user interface with a menu
- The File-Open option on the menu launches a file browser that
allows the user to select a file to read
- Your program then opens a byte stream attached to the file for
reading
- it reads in the contents of the file into a byte array
- it runs through the array and displays
the 8-bit
binary representation of each byte read, for instance in a text
area. Separate
adjacent bytes with a blank space
in your viewer.
To test your program: Use Notepad to save the characters ABC
into a file. Use your
binary file viewer to read the file. What to do you see ?
Use your program to read and display the contents of this
file. Can you determine what was written to the file ? Use the links at
the bottom of the page to check your response later.
If you are so inclined, you can start with
the File
Viewer program (the program also uses the File Manager class)
and modify it to suit your purposes. However, it may be easier to
simply write your own program from scratch.
This
is what was written to the file, and here is the program
that produced both data files.