Use Irfanview (or other hex dump program) to examine the contents of several text files and binary files.
When you examine a text file, the hex dump will show the bit patterns that represent the characters (using the ASCII scheme). The right side of the display will show the characters that are represented. For example, here is the display of a text file created with NotePad:
It shows that the very first byte of the file contains the bit pattern 0x57 (which is 01010111) and that this pattern represents the character 'W' .
Bit patterns are represented using hexadecimal notation, where every four bits form a pattern and each pattern is given a name according to this scheme:
Click here to go back to the main menu.
Write a program that writes a file the values 0 to 64 using data type
writeShort()). Examine the file with a hex dump.
Now write a program that writes a file the values 0 to 64 using data type
writeInt()). Examine the file with a hex dump.
Now write a program that writes a file the values 0.0 to 64.0 using data type
writeDouble()). Examine the file with a hex dump.
Write a program that asks the user for the name of an input text file. The text file (which could be created with NotePad) will contain integers in character format, one per line, such as follows.
12 1023 -56 84781 0 -9371
The program also asks for the name of an output file.
The program then reads the input file line by line until end of file.
Each input integer is translated
int data (use
and written to the output file using
Look at the input file and output file with the DOS command DIR and, if possible, with a hex dump program.
C:\Programs>java IntCopy Input file -->ints.txt Output file -->ints.bin C:\Programs>dir 06/16/00 04:33p 1,881 IntCopy.class 06/16/00 04:33p 1,920 IntCopy.java 06/16/00 04:35p 24 ints.bin 06/16/00 04:35p 30 ints.txt
Write the input loop so it catches
and echos the offending line.
Here is another input file:
0 1 2 3 4 Rats, this won't work 6 7 8
And the corresponding run of the program:
C:\Programs>dir Input file -->oops.txt Output file -->opps.bin Poor input data:Rats, this won't work C:\Programs>Click here to go back to the main menu.
End of Exercises.