Bonjour j'ai une question d'un QCM à laquelle je n'ai pas su répondre.
La question est StreamPrinter.print(Reader reader) n'est pas robuste
Améliorez StreamPrinter.print(Reader reader)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 import java.io.IOException; import java.io.Reader; class StreamPrinter { void print(Reader reader) throws IOException { int code = reader.read(); while (code != -1) { System.out.println((char) code); code = reader.read(); } reader.close(); }
Partager