• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileOutputStream  RSS feed

 
Aru
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Which of the following statements are true, given the code new FileOutputStream("output.txt", true) for creating an object of class FileOutputStream?
a. No matching constructor.
b. It may throw a SecurityException but will never throw FileNotFoundException bcoz of the 2nd parameter which is true.
c. If a file named "output.txt" exists, its contents will be reset & overridden
d. If a file named "output.txt" exists, output will be appended to its current contents.
When I looked into the API, It says,
" If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown."
But never could I find that the file will be over written or appended.
Your help is appreciated.
Thx
Aruna
 
N Mukherjee
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi aruna,
With the help of this constructor, output will be appended
to the file(existing or non-existing).File gets created if it
is not existing.
Hope this helps.
NM
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am moving this thread to IO and Streams forum.
Perhaps that's a better place to discuss this issue...
Ajith
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!