Question from Javacaps mock exam 55. You have an 8-bit file using the character set defined by ISO 8859-8. You are writing an application to display this file in a TextArea. The local encoding is already set to 8859-8. How can you write a chunk of code to read the first line from this file? You have three variables accessible to you: myfile is the name of the file you want to read stream is an InputStream object associated with this file s is a String object Select all valid answers. A) InputStreamReader reader = new InputStreamReader(stream, "8859-8"); BufferedReader buffer = new BufferedReader(reader); s = buffer.readLine(); B) InputStreamReader reader = new InputStreamReader(stream); BufferedReader buffer = new BufferedReader(reader); s = buffer.readLine(); C) InputStreamReader reader = new InputStreamReader(myfile, "8859-8"); BufferedReader buffer = new BufferedReader(reader); s = buffer.readLine(); D) InputStreamReader reader = new InputStreamReader(myfile); BufferedReader buffer = new BufferedReader(reader); s = buffer.readLine(); E) FileReader reader = new FileReader(myfile); BufferedReader buffer = new BufferedReader(reader); s = buffer.readLine(); Given ans : Only A But why not [B] if the local encoding is already set to 8859-8. The rest of the code is same. and [E] FileReader which is again subclass of InputStreamReader reads with default local encoding Comments please Amit
Amit Punjwani
Ranch Hand
Joined: Jul 10, 2000
Posts: 50
posted
0
Someone please help me with this question Thanx in adv Amit
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.