Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-27-2008, 06:09 PM
Member
 
Join Date: May 2008
Posts: 2
elvinny is on a distinguished road
Hashmap to TXT and TXT to Hashmap
Hi!!!
I'm Luis from Portugal and i would like to know how i can save values from a HashMap(huge size) to a text file(.txt, .dat or something else that can be read). After that how can i load that file to a HasMap.

Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-27-2008, 06:55 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
It depends on you.... ( structuring patterns )

You can use FileWriter class for saving values in a file.

You can use Scanner class for reading back the generated text file.
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-27-2008, 07:55 PM
Member
 
Join Date: May 2008
Posts: 2
elvinny is on a distinguished road
I'm using an Hashmap to keep float values:

Code:
... public HashMap qValues = new HashMap(10000,(float)0.75); ... qValues.put(p.hashCode(), new Float (v)); ...

p is a class of two different strings (Pair state/action). The hash code generated is the sum of the hash code of each different string
v is the value i want to keep (Q value in Reinforcement Learning )

Thanks for the reply
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-27-2008, 08:51 PM
Chris.Brown.SPE's Avatar
Member
 
Join Date: Apr 2008
Location: State College, PA
Posts: 50
Chris.Brown.SPE is on a distinguished road
Send a message via AIM to Chris.Brown.SPE
I've seen this question quite a few times and have never seen an easy fix for it. I with there was a .toString() function that had all of the values in it, but there aren't. So unless you find something we all haven't you are going to have to traverse the hashmap saving each value then read them back in and put them back into the hashmap for loading. It should be pretty trivial to program, but it will not be quick on large data. Goodluck.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HashMap with objects otoro_java New To Java 2 01-28-2008 05:28 PM
HashMap visual example jhetfield18 Advanced Java 1 12-12-2007 09:45 PM
Hashmap dirtycash New To Java 5 12-03-2007 04:58 AM
HashTable vs HashMap bugger New To Java 3 11-29-2007 02:28 PM
what is hashmap gabriel New To Java 5 08-03-2007 03:23 PM


All times are GMT +3. The time now is 12:37 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org