File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to write the hashtable to a file

 
jack zhang.China
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello guys:
i want to write a hashtable to a file,but didn't know how
 
Kia Phia Ben
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I loop Enumeration and get value from key. Next step you write file.
 
Martin Simons
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply write the hashtable.toString() string to a file.

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you intend to read it back later? Martin's solution isn't very useful when your program has to read it back later.

Does the output have to be in text format or can it also be binary?

See the Java Tutorial on serialization for an alternative solution.
 
Martin Simons
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually with the format that is written using toString on a hastable
it is not hard at all to read it back with a simple parser, which then
allows you to make it human readable and still be reusable. It is not
true serializing, true, but I also did not mean it to be.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic