• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FileOutputStream

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic