Filter Streams   «Prev  Next»

Java Streams Portable Formats - Exercise

Write a program that reads a file of floating point radii and writes a file of floating point circumferences. Both files should be binary files of floating point numbers (i.e. binary files in which every 4 bytes signify a floating number according to the IEEE-754 standard).
Just in case you can not remember,
circumference = 2 * pi * radius. 

To test your program, use the sample input data file Float.dat contained in the jstreams folder of the course download file.
To print out the contents of your input and output files to the screen, you can run PrintFloat.class (also in the jstreams folder).
For example, to run the program RadiiToCircumference using Float.dat as the input file and writing Answer.dat as the output file, you would type:
java RadiiToCircumference Float.dat Answer.dat

To check to see that RadiiToCircumference works as expected, you can print out the content of Answer.dat by running PrintFloat and using Answer.dat as its input file:
java PrintFloat Answer.dat
Paste the source code below and click the Submit button when you are ready to submit this exercise.