Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

input/output

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks Erin.
 
antraarora
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Erin!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic