Results 1 to 8 of 8
- 02-15-2009, 09:04 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
reading data from text file .. help plz
Hi every body ,,
Happy Valentine Day
I'm new member and I really I have no clue in JAVA. I have download BlueJ and the JDK ,,,
I'm trying to do the following :
I want to Implement the following problem in Java.
I have two files , employe.txt and transaction_file.txt
The master employe.txt file has the following layout:
Employee_ID_number, Last_Name, First_Name, Salary, Number_Dependents, Department,
The transaction_file.txt has the following layout:
1657, D
3982, A, Fred, Lincon, 56534, 1, Shipping
0192, U, cooper
0190, A, abdul, Tilli, 89855, 0, Accounting
A = Add a record
U = Update a record
D = Delete a record
I want to make a progame which can read the files. no user input. The I can just pass through the employee file and one pass through the transaction file in a staggered stair step fashion. In other words I don't want take the first transaction record and search all the way through the employee list, then take the second transaction record and search all through the employee list again, and so on. I hope you got my idea ...
The program should generate the following transaction log.
1657 D record not deleted, record does not exist
3982 A record not added, record already exists
0192 U record Updated.
0190 A record Added
I really spent 48 hours trying to do it but I could not
Could you help me please ??!!
- 02-15-2009, 09:20 AM #2
Member
- Join Date
- Feb 2009
- Posts
- 48
- Rep Power
- 0
man you gotta walk before you can run.. this would take me awhile and ive been programming for a month. start with some tutorials.
- 02-15-2009, 09:22 AM #3
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
Thank you for being optimistic !! loooooooooooooooooool
- 02-15-2009, 09:22 AM #4
Member
- Join Date
- Jul 2008
- Posts
- 67
- Rep Power
- 0
If it's not your home assignment why not to use some lightweight database ? So you can make two tables and join them, which would be much more effective.
I recommend to use Hsqldb or SQLite.
-
Because given the nature of the restrictions on how to solve this, it is most obvious that it in fact is his homework assignment and as such, the original poster should be the one to do it.
to the original poster, we are great at answering specific questions or helping find a subtle bug in a piece of posted code, but unfortunately don't do very well at helping questions of your type which are known as "homework dumps": were folks drop the complete assignment here and claim that they don't know where to start. Please realize that we're all volunteers with lives, jobs, families and time constraints and all, and what you really need is a way to jump-start your Java education through intense study and tutoring.
I strongly suggest that you get up with your tutor and start reviewing your material so you can catch up with the rest of your class. Also study the basic Sun Java tutorials that you can find here:
Trail: Learning the Java Language (The Java™ Tutorials)
Good luck
- 02-15-2009, 10:03 AM #6
Drunk up the stairs?
staggered stair step fashoin? Never heard of it... could you please explain?...and one pass through the transaction file in a staggered stair step fashion
Thanks,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 02-15-2009, 06:17 PM #7
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
hi guys
I don't want you to solve this or to give me the code ! , all what I want just give a hint about it
I'm trying to do it by myself and since that I can not find any tourer , so just if you guys give me any idea , any guideline ,,, , I will be so happy with that
Thank you anyway
- 02-15-2009, 07:29 PM #8
Here's a good way to do it I found on the internet.
Java Code:private String readFileAsString(String filePath) throws IOException { StringBuilder fileData = new StringBuilder(1000); BufferedReader reader = new BufferedReader( new FileReader(filePath)); char[] buf = new char[1024]; int numRead = 0; while((numRead=reader.read(buf)) != -1){ fileData.append(buf, 0, numRead); } fileData.trimToSize(); reader.close(); return fileData.toString(); }Tell me if you want a cool Java logo avatar like mine and I'll make you one.
Similar Threads
-
Reading Integers from a text file
By tress in forum New To JavaReplies: 6Last Post: 02-26-2011, 05:45 PM -
Problem with reading text from a .txt file
By Gigi in forum New To JavaReplies: 40Last Post: 01-22-2009, 03:22 AM -
Reading two text file and sum them up
By matt_well in forum New To JavaReplies: 36Last Post: 07-22-2008, 02:55 AM -
Reading text file
By Lennon-Guru in forum New To JavaReplies: 1Last Post: 12-15-2007, 11:38 PM -
Reading Data from a file
By ramachandran in forum New To JavaReplies: 2Last Post: 10-24-2007, 07:22 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks