Write a Binary File Viewer
that can display the contents of a file in binary. Your program will
feature
To test your program: Use Notepad to save the characters ABC into a file. Use your binary file viewer to read the file.
Add a menu option to your Binary File Viewer to open a bitmap image and replace the green in the rgb values for those green intensities greater than 127 with black and save this file with the same file name and extension with "Modified" appended to the name. This code may be useful:
public static void download(File inFile, File outFile) throws IOException {
InputStream in = new FileInputStream(inFile);
FileOutputStream out = new FileOutputStream(outFile);
byte[] b = new byte[1024]; //consider
making the byte array the same size as the file
int len;
while((len = in.read(b)) != -1) { //the read method is
overloaded so its behavior varies by the input parameter
out.write(b, 0, len);
//modify those bytes that represent green with intensity > 127 before writing the byte
array
}
out.close();
}
public static void download(URL url, File file) throws IOException {
InputStream in = url.openStream();
FileOutputStream out = new FileOutputStream(file);
byte[] b = new byte[1024];
int len;
while((len = in.read(b)) != -1) {
out.write(b, 0, len);
}
out.close();
}
A discussion of the bitmap format can be seen
here. After reading the discussion, view the contents of the following files
to help determine the file layout: red.bmp,
green.bmp, blue.bmp. Save these
files, right click and view properties to determine more about the format of
these files. The base URL for these files is
http://torvalds.bearlabs.uncw.edu/~tompkinsj/221/Fall04/Lab12b/
Answer the seven questions in the body of your email with your zipped project
folder
attached:
Based on Dr. Narayan's Lab 5 , Modified by Jack Tompkins