File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InputStream question required

 
VINCE CARTER
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1:
Which two create an InputStream and open file the �file.txt� for reading? (Choose Two)
A. InputStream in=new FileReader(�file.txt�);
B. InputStream in=new FileInputStream(�file.txt�);
C. InputStream in=new InputStreamFileReader (�file.txt�, �read�);
D. FileInputStream in=new FileReader(new File(�file.txt�));
E. FileInputStream in=new FileInputStream(new File(�file.txt�));
Answer: B, E
2:
Which two construct an OutputSream that appends to the file �file.txt�? (Choose Two)
A. OutputStream out=new FileOutputStream(�file.txt�);
B. OutputStream out=new FileOutputStream(�file.txt�, �append�);
C. FileOutputStream out=new FileOutputStream(�file.txt�, true);
D. FileOutputStream out=new FileOutputStream(new file(�file.txt�));
E. OutputStream out=new FileOutputStream(new File(�file.txt�)true);
Answer: C, E

Does the answers are right ?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Insert the missing comma in 2.E, and I think you got it.
 
VINCE CARTER
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What ??
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you will find the answer by reading theAPI for FileOutputStream.
[ September 27, 2004: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Dirk means change:
OutputStream out = new FileOutputStream(new File(�file.txt�)true);

to

OutputStream out = new FileOutputStream(new File(�file.txt�), true);

in Question 2, E and this SCJP 1.2 answer will be correct.
 
PETER CARTER
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I mean :
If we choice B and E for 1,we should choice A and D for 2.
But it's wrong ,why ??
Thanks !!!
Help me in your heart !!
 
Ramesh Kale
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Sorry for posting the thread.
I read that all objectives of scjp1.4 there is no any object realted with java.io.

I am right? on above statement.
Please corrent me if i am going wrong.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right. IO is not in SCJP 1.4.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic