• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

input/output

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not think answer A is correct as
InputStreamReader does nor have constructor with two aruments.
- Thanks
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Erin.
 
antraarora
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Erin!
 
reply
    Bookmark Topic Watch Topic
  • New Topic