-
Notifications
You must be signed in to change notification settings - Fork 1
Module 10 Mastery Check
wolvesled edited this page Sep 16, 2013
·
1 revision
- Why does Java define both byte and character streams? Answer: byte stream for low level support and legacy uses, character stream for internationalization because it is unicode encoded.
- Even though console input and output is text-based, why does Java still use byte streams for this purpose?
- Show how to open a file for reading bytes. Answer: FileInputStream fin = new FileInputStream("filename.ext")
- Show how to open a file for reading characters. Answer: DataInputStream fin = new DataInputStream("filename.ext")
- Show how to open a file for random access I/O. Answer: RandomAccessFile raf = new RandomAccessFile("filename.ext", access)
- How can you convert a numeric string such as "123.23" into its binary equivalent?
- Write a program that copies a text file. In the process, have it convert all spaces into hyphens. Use the byte stream file classes.
- Rewrite the program described in question 7 so that it uses the character stream classes.
- What type of stream is System.in? Answer: InputStream
- What does the read() method of InputStream return when the end of the stream is reached? Answer: -1
- What type of stream is used to read binary data? Answer: DataInputStream and DataOutputStream
- Reader and Writer are at the top of the ____________class hierarchies. Answer: character stream