Professional Documents
Culture Documents
Java Programming Language: in This Session, You Will Learn To
Java Programming Language: in This Session, You Will Learn To
Ver. 1.0
Session 8
Slide 1 of 20
Ver. 1.0
Session 8
Slide 2 of 20
Ver. 1.0
Session 8
Slide 3 of 20
Ver. 1.0
Session 8
Slide 4 of 20
Ver. 1.0
Session 8
Slide 5 of 20
Ver. 1.0
Session 8
Slide 6 of 20
Ver. 1.0
Session 8
Slide 7 of 20
Ver. 1.0
Session 8
Slide 8 of 20
Ver. 1.0
Session 8
Slide 9 of 20
Ver. 1.0
Session 8
Slide 10 of 20
The application program can use the following methods of the java.io package to read from a text file and display each line on the standard output.
Create file: File file = new File(args[0]); Create a buffered reader to read each line from the keyboard: BufferedReader in = new BufferedReader(new FileReader(file));
Ver. 1.0
Session 8
Slide 11 of 20
Ver. 1.0
Session 8
Slide 12 of 20
Ver. 1.0
Session 8
Slide 13 of 20
Ver. 1.0
Session 8
Slide 14 of 20
Ver. 1.0
Session 8
Slide 15 of 20
Ver. 1.0
Session 8
Slide 16 of 20
Ver. 1.0
Session 8
Slide 17 of 20
Ver. 1.0
Session 8
Slide 18 of 20
Session 8
Slide 19 of 20
The Iterator interface enables you to scan forward through any collection. The enhanced for loop can be used to iterate through a collection. Generics provide compile-time type safety and eliminate the need for casts.
Ver. 1.0
Session 8
Slide 20 of 20