IC211 Spring AY 2020
Name (Last, First): ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
Apple.java
|
Jazz.java
|
Fruit.java
|
|
|
|
Take a look at this program
which is a tool for analyzing files. If you have a
file foo
,
then cat foo | java HW10
will tell you whatever
the program is able to determine about the type of the
file foo
.
Your job is to extend it so that in addition to recognizing ASCII files and JPG files, it also recognizes PDF files (which begin with four bytes corresponding to the ASCII characters %, P, D, and F (i.e. bytes %PDF). You may not modify the files Categorizer.java, RecogASCII.java or RecogJPG.java, but you may modify HW10.java and you may create new classes.
Don't get overwhelmed. Look at HW10.java and think about how to add a PDF recognizer. Then look at RecogASCII.java and think about how to make your own PDF recognizer. You don't have to thoroughly understand all the other code.
Download these input files to your directory with your Java solution: hw10in1, hw10in2, hw10in3, hw10in4. And then test your program as follows:
cat hw10in1 | java HW10 // should output JPG cat hw10in2 | java HW10 // should output PDF cat hw10in3 | java HW10 // should output ASCII cat hw10in4 | java HW10 // should output ASCII
If you don't want to manually download them, you can alternatively use curl to pipe the download directly to your program:
curl -s http://faculty.cs.usna.edu/IC211/docs/hw10in1 | java HW10 // should output JPG curl -s http://faculty.cs.usna.edu/IC211/docs/hw10in2 | java HW10 // should output PDF curl -s http://faculty.cs.usna.edu/IC211/docs/hw10in3 | java HW10 // should output ASCII curl -s http://faculty.cs.usna.edu/IC211/docs/hw10in4 | java HW10 // should output ASCII
codeprint
!) of HW10.java and ANY NEW .JAVA files you created, along with a screencapture showing your program's output on the above examples. Do not print out the .java files that we provided for you.