Use socket method. "in" is an InputStream constructed by "InputStream in = new Socket().getInputStream();" Which constructor is the most adequate for transmition of ASCII data from the socket? A. BufferedReader(InputStreamReader(in, "8859_1")) B. BufferedReader(InputStreamReader(in)) C. DataInputStream(in) D. BufferedInputStream(DataInputStream(in)) E. InputStreamReader(in) The given answer at the back of book is A. Can someone expalin why? I am clueless.
Hi, A is correct. Class InputStreamReader has two constructors: 1. InputStreamReader( InputSretam ins ) This creates a reader that reads bytes in the default character encoding. 2. InputStreamReader( InputStream ins, String encoding ) This creates a readere that reads bytes in the specified character encodind. BufferedReader can be chained to underlying reader such as InputStreamReader to read text lines using the 8859_1 character encoding.