This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Can you 'save' tree maps? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can you Watch "Can you New topic
Author

Can you 'save' tree maps?

Conrad McLaughlin
Greenhorn

Joined: Jan 31, 2006
Posts: 27
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?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
jQuery in Action, 2nd edition
 
subject: Can you 'save' tree maps?
 
Similar Threads
Is there a tree style component available for jsp?
What every developer should know about character encoding
Newb needs a lot of help...
File parsing with header info dynamic
Anyone know How to solve this basic problem?