Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

DataInputstream  RSS feed

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ALL,
This question is from Marcus Green's mock test.
1) Which of the following are legal?
a)File f = new File("/","some.txt");
b)DataInputStream s = new DataInputStream(System.in);
c)OutputStreamWriter o = new OutputStreamWriter(System.out);
d)RandomAccessFile f = new RandomAccessFile("some.txt");
Answer: a,b,c
I thought the answer was only 1 since Filter Input/OutputStreams need a low level input stream (like FileInputstream etc) in the input arguments. Can somebody expain to me why the answers are a,b and c?
Thanks,
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.in is a low-level InputStream, and System.out is a low-level OutputStream.
 
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The constructors are
DataInputStream(InputStream in)
and
OutputStreamWriter(OutputStream out)
OutputStreamWriter(OutputStream out, String enc)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!