I have two java classes: LecturaEscrituraObjetos and Venta. The first one is where are the methods to write and read objects from a file and it has the hashtable named th where the objects Venta are saved. The second one is the object that I want to write and read from a file.
There are no errors. The problem is that I don't know the way to access the methods of the object Venta from the hashtable. I tried it using toString(), Values() and Elements() methods but I only see something like Venta@1d009b4. I also tried use the Enumeration interface but I don't know how to copy the elements from the hashtable to the Enumeration.
I can see problems with your Venta class. You have lots of fields, but you do not initialise them in your constructor. You have a Scanner object, which you never use, so you might as well delete it.
You ought to provide a constructor which initialises the Venta object and getXXX methods which allow access to its fields. You should find some similar examples here. All the fields should have private access, so access can only be through the getXXX methods.
As for the output, Venta@17ce4e7, start reading here.
why are you using Hashtable, which is legacy code? Why are you using floats?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Objects attributes accessing from a hashtable