Given the code fragment:
public void ReadFile (String source) {
char[] c = new char [128];
int cLen = c.length;
try (FileReader fr = new FileReader (source)) {
int count = 0;
int read = 0;
while ((read = fr.read(c)) != -1) {
count += read;
}
System.out.println(“Read: ” + count + ” characters.”);
} catch (IOException i) {
}
What change should you make to this code to read and write strings instead of character arrays?
A.
ChangeFileReader to Readers.
B.
ChangeFileReader to DataReader.
C.
ChangeFileReader to File.
D.
ChangeFileReader to BufferReader.
Explanation:
public class BufferedReader
extends Reader
Read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.
The buffer size may be specified, or the default size may be used. The default is large enough for most purposes.
ChangeFileReader to BufferedReader.
+1, there is no “DataReader” (only “DataInputStream” available).
The answer is D.
Hi All,
I’m going to write an exam of Java SE 8 Programmer-II[1z0-809] on 08-Jan-2017.
If you guys have this dump please send me on [email protected] . It will be great help me. Thank you so much.
Hi I am planning to write 1z0-804. Anybody has dump material then please send it to me at [email protected]. I will be very grateful…. plzz