• 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

DataOutputStream(new FileOutputStream(aFile, true));

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to use a DataOutputStream to write an array to a file called aFile. I want the new records to be appended to the end of the existing file. This code compiles fine, but I get a 'NoSuchMethodError' when the oStream is declared. It works if it is declared with 'FileOutputStream(aFile)', but it overights the first record in the file every time this it is called. Any idea on what's happening?


Thanks,
Mark
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure that when you tried using the boolean parameter that you didn't misplace it? Are you sure it was inside the parentheses after FileOutputStream, and not outside of them, but inside the ones after DataOutputStream?
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to use a DataOutputStream to write an array to a file called aFile. I want the new records to be appended to the end of the existing file. This code compiles fine, but I get a 'NoSuchMethodError' when the oStream is declared.
The 'NoSuchMethodError' probably means you have a corrupted installation or a CLASSPATH that is pointing to the wrong runtime library. The only way this can happen is if the class somehow changes between compile time and runtime assuming that it compiles without complaint. But as Ernest said, check all the obvious things first.
 
Mark Patrick
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michelle,
Thanks. I didn't realize that Oracle had previously installed two older versions of the JRE. They were both before the current version of the JRE in the path. I removed them from the path and it worked perfectly. That was an interesting lesson to learn!
Mark
 
Mark Patrick
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,
Sorry. (Not Michelle).
Mark
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Patrick:
Michael,
Sorry. (Not Michelle).
Mark


That's OK Mark, we all need to get in touch with our feminine side now and again.
By the way, welcome to JavaRanch and we hope to see you around here some more.
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic