• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Input/Output(urgent)

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Reading one line of data at a time from a socket connected to the network
with an input stream object s. The output to be in standard ASCII character
encoding.
(a)DataInputStream da = DataInputStream(s.getInputStream());
(b)DataInputStream do = DataInputStream(FileInputStream(g.getInputStream());
(c)BufferedReader b= new BufferedReader
(newInputStreamReader(s.getInputStreamReader));
(d)BufferedReader b= new BufferedReader
(newInputStreamReader(s.getInputStreamReader), "8859_1");
2. what is the correct format of reading a line of
String objects ?
a) FileInputStream fis = new
FileInputStream("Filename.txt");
b) DataInputStream dis = new DataInputStream(new
FileInputSTream("FileName.txt"));
c) DataInputStream dis = new DataInputStream(new
FileInputSTream("FileName.txt"), "r");
Can anyone help me.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai peter ,
for the 1st queswtion as per my knowledge the ans should contain the ASCII code as the last argument in the constructer so the ans
may be 'd'
hope this will help u,
if wrong correct me
tnks,
krishna
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.
b is the correct answer.
d would have been correct if the arguments were passed correct.
BufferedReader b= new BufferedReader
(newInputStreamReader(s.getInputStreamReader), "8859_1");
the "8859_1" String parameter should be in the constructor of
InputStreamReader.
2. b is the correct answer
This question is asked by Janani, and eplanation is given for
this in that post.
All,
I am a buddy to this group and can I know what "green horn"
means.
Thanks
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) A is correct. Because the stream is said to be standard ASCII encoding we don't need a Reader(?). Only A has a valid constructor. In B, FileInputStream doesn't take an InputStream, only String, File and FileDescriptor.
2) If the FileInputSTream is a typo (FileInputStream) then B is correct, otherwise none.
 
Hug your destiny! And hug this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic