Chapter 10: Using I/O: Copyfilechangespacetohyphen2.Java

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Chapter 10: Using I/O

1.

Because Javas I/O system is quite large, containing many classes, interfaces,
and method. Thus it is better to separate the two I/O Systems from each

2.

other.
Because using bytes streams System.in to read character from keyboard

3.

is more convenient that using character streams.


Open a file for reading bytes:
try{
FileInputStream fin = new FileInputStream("fileName");
}catch(IOException exc){System.out.println("I/O Error" + exc);}

4.
5.

Open a file for reading characters:


try{
BufferedReader br = new BufferedReader(new FileReader("filename"));
}catch(IOException exc){System.out.println("I/O Error" + exc);}

6. We can convert numeric string 123.23 in to binnar equivalent by using type


wrapper Double. So, double d = Double.parseDouble(123.23);

7.
CopyFileChangeSpaceToHyphen.java
8.
CopyFileChangeSpaceToHyphen2.java
9. System.in is bytes tream
10. It will return -1.
11. DataInputStream
12. Reader and Writer are at the top of the character stream.
13. The try-with-resources statement is used for automatic closing a file.
14.True.

You might also like