• 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

Can you 'save' tree maps?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bit of a weird question, i am a java novice so I hope its not silly.

Can you save a tree map externally from a java file?

The reason being that is that I have a java program that adds words from text files to a tree map. The text files never change, and a lot of time is spent reading the text files into the tree map every time you re-run the program.

So it was wondering if there was a way of 'saving' the treemap to an external file and the 'loading' the tree map at the start of the program to save time of reading the text files again on each load.


hmmm...(do I make sense?)



Ps. What exactly is saved in the class files which are produced when i compile java programs?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class java.util.TreeMap implements java.io.Serializable, so you can write the object directly to file using java.io.ObjectOutputStream. Have a look at the Java Tutorial chapter on Object Serialization to see how it is done.
As for what the contents of a class file are, it's called bytecode, sort of like a native executable file for the Java Virtual Machine. Have a look at this article for some examples.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic