• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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: 24204
44
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.
 
It's feeding time! Give me the food you were going to give to this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic