• 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

input/output

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi
1:Connected to a socket s, read one line of ASCII char. Please construct the right input method:
- InputStream in = new InputStream(s.getInputStream());
- DataInputStream in = new DataInputStream(s.getInputStream());
- BufferedReader in = new BufferedReader(InputStreamReader(s.getInputStream());
- BufferedReader in = new BufferedReader(InputStreamReader(s.getInputStream(), "8859_1");
Use socket method. "in" is an InputStream constructed by "InputStream in = new Socket().getInputStream();"
2: Which constructor is the most adequate for transmition of ASCII data from the socket?
- BufferedReader(InputStreamReader(in, "8859_1")) // his choice
- BufferedReader(InputStreamReader(in))
- DataInputStream(in)
- BufferedInputStream(DataInputStream(in))
- InputStreamReader(in)
3:You want to use the readLine() method which of the following will be the correct initialization?
a) BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream("file","8859_1")))
b) BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream("file")))
c) DataInputStream ds = new DataInputStream(new FileInputStream("file"))

4:What kind of Stream does DataInputStream accept?
what are the valid type of arguments for different types of streams & readers/writers...
can anybody ans these question.i am totally confused when i get these type of questions...
can anybody help with this..(any notes on this topic)so that i can read..& be ready for the exam..
thanx
sherinn
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is one link: http://www.geocities.com/SiliconValley/Network/3693/java_cert.html
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer to Qn1.
-There is no readLine() method in InputStream.
-readLine() method is deprecated in DataInputStream.
-unbalanced parentheses and Argument to BufferedReader() is not correct.
-same as above.
The Correct answer I believe should be something like this.
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
Or
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()),"8859-1");
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am transferring this post to I/O and Streams forum
Ajith
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic