• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
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
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)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!