File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Reading and Writing Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading and Writing Objects" Watch "Reading and Writing Objects" New topic

Reading and Writing Objects

Joey Jacobs

Joined: Mar 16, 2006
Posts: 1
Hello there! Ok, here is the background for what I am trying to do.

1) The program will read the original sales data from SalesData.txt, that will create salesmen and then that information will be entered into the array list Salesman. The file looks like this (just so ya know):


2) The user will be able to enter additional data on the GUI, either a new salesman and his product sales or the user can update an existing salesman.
3) Then once all of the data is entered the data will be written to the as objects instead of text.
4) Then also added to the GUI will be an additional button that when it is clicked the user will actually read the file, put the information in a vector, sort it, and then last prints the information to the output area on the GUI in alphabetical order (as it did before).

The above mentioned steps I have been working on and so far the code below is where I am at and I am little bit stuck. There are two other things I must do to this code, but I figured I should worry about the other stuff first. The other two things are:

1) Each salesman has a level type of ENTRY, JUNIOR, or SENIOR. There will be an enumerated class for the sales type. There is a variable, bonus, associated with each type. The bonus for SENIOR is 15%. The bonus for JUNIOR is 10%, and the bonus for ENTRY is 5%.
2) I need to create a NoSalesException. This exception will be thrown from calculateSales and handled from the calling method. To handle this exception, I will print a warning message dialog box that states the name of the salesman and that he has no sales.
* But, I figured I would get the first few steps going first then worry about those two.

So, if anyone has any comments or ideas for me, please just let me know. I need all the help I can get with this one. Also, I am sorry if my description/explanation of the application I am trying to code is too detailed, I wasn't sure if I should go into a ton of detial or not. So I just thought I would give a good description to begin with that way you had a good understanding of what I am trying to do. Again, if anyone has any tips, ideas or help...please please let me know! Much appreciated!!

Thanks again!!! Any little tips to help me get going again would be awesome!
Srivatsan santhanam

Joined: Jan 04, 2006
Posts: 23
Why don't you use XML data representation?

Using XML is not trying to use all *Hi-Tech* methodologies in you program, but trying to be flexible and manipulate the info in a efficient manner

When you parse the XML, you automatically get the DOM tree representation. From there on its very easy to do any kind of query/manipulation like variable Bonus, and other operation you might want to introduce later´┐Ż

Any day, I would vouch for XML data representation rather than flat files using string delimiters. (Not because the data storage looks neat and orderly, but because the kind of operations I can do with XML data representation. Also Java+XML work really well together.!!)


Java Objects passed by Reference ?? -> you are a failure !!
I agree. Here's the link:
subject: Reading and Writing Objects
It's not a secret anymore!