|
Note | The solutions to these exercises are in Appendix B. |
In this chapter, you learned about the following line:
String s = "C:my_backup\temporary\news";
What does the following code print out?
String s = "C:my_backup\temporary\news"; System.out.println("***\n" + s + "***");
What is the moral of this exercise?
The code examples in the "Writing and Reading Data" section defined an int called i, a float called f, a double called d, and so on. But the long was called n, which breaks the pattern. You might have expected the long to be called l. Why do you think this was not done?
Write a program that creates a file containing 5,000 random doubles that are >= 0 and <200.
Write a program that verifies the file you created in the previous exercise. Your program should read the 5,000 doubles, making sure that each falls within the proper range. Your program should also make sure the file contains exactly 5,000 longs.
Look up the API documentation for the java.io.File class. An instance of this class contains information about an individual file. One of the methods of the class tells you the length in bytes of a file. Use this method to determine the number of bytes in the file you created in Exercise 3.
|