Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read transactions from multiple files simulatenously

Posted on 2004-04-10
5
Medium Priority
?
270 Views
Last Modified: 2012-05-04
write a Java program that manages a simple checking account.
There are 2 simple transactions: deposit and withdrawal. Both transactions come from a simple text file with the following columns: customer_last_name, branch, branch_account_number, transaction, amount. For example:

Silver            1000      001      withdrawal      20
Smith            1001      001      withdrawal      40
Black            1000      002      deposit            20
Bush            1003      005      deposit            100
Silver            1000      001      withdrawal      40

Note that branch_account_number is only unique within a branch!

Your program should be able to read transactions from multiple files simultaneously (think how you are going to protect the integrity of your data). The program should execute the transactions, maintaining the right balances. You may hardcode the number of input files (where transactions are stored). You do not have to remember the exact syntax of file operations, etc. Make reasonable assumptions. Remember that file i/o may fail, you have to handle exceptions gracefully.
0
Comment
Question by:m_nekkanti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 24

Accepted Solution

by:
sciuriware earned 1500 total points
ID: 10797600
As you may know on EE we are not allowed to do your homework.
All I can say is: try a construct with a thread per file that reads a file as it grows.
If you want an alternative, you will end in multiple external programs that send data to a pipe read in the JAVA program.
It depends on the O.S. what can be done.

But please do not expect a complete written solution here!

You may post some code that you already have to have it scrutinized by us.

;JOOP!
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10804187
In order to maintain your transactions,

Keep all your data buffered until all the operations are completed.  Persist the data when the transaction is successful.

RandomAccessFile would help you in updating/reading a file.


Regards,
Muruga
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10804209
If there is a IO Failure, the contents won't persist in the file.   You can rollback the transaction by doing nothing.

0
 

Author Comment

by:m_nekkanti
ID: 10822609
I aked for help, the direction how I can proceed. Because I dont have experience in multithrading, deadlocks.
How can I remove this question from this forum?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question