• 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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