Download - Chapter 10

Transcript

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 other.2. Because using bytes streams System.in to read character from keyboard is more convenient that using character streams.3. 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.java8. CopyFileChangeSpaceToHyphen2.java9. System.in is bytes tream10. It will return -1.11. DataInputStream12. 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.


Top Related