|
|
|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

08-20-2008, 12:37 PM
|
|
Member
|
|
Join Date: Aug 2008
Posts: 39
|
|
|
How to Modify,Delete data in File Txt???
I have some record in File *.txt like this:
Write and Read i use FileWriter+BufferedWriter & FileReader+BufferedReader
AccountNumber AccoutnName AccountBalance
1 aaa 100
2 bbb 200
3 ccc 300
Example:
how can i modify the AccoutnName "bbb" to "ccc" or "ddd" ???
how can i delete a second record???
Write and Read i use FileWriter+BufferedWriter & FileReader+BufferedReader
I really need help!
Thanks!
|
|

08-20-2008, 12:41 PM
|
 |
Member
|
|
Join Date: Jul 2008
Posts: 67
|
|
|
Store the modified records in tem.txt file ..
delete the original file ..
and rename the temp file to original name ..
|
|

08-20-2008, 12:46 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
In such a case what I'm doing is read the file store them in a collection. Then it's easy to do any manipulation on it. Finally write all data to a file.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Someone helped you? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post. Help: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Resources: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Web: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tips: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

08-20-2008, 01:34 PM
|
|
Member
|
|
Join Date: May 2008
Posts: 27
|
|
|
If he is having a 500000 and above records, then the above ideas are not efficient right? If that is the case, what you guys suggest.I mean is there any Persistent Collection Object to handle this kind of situation.
|
|

08-20-2008, 02:18 PM
|
 |
Member
|
|
Join Date: Jul 2008
Posts: 67
|
|
|
Hmmmmm.
Originally Posted by nanaji
If he is having a 500000 and above records, then the above ideas are not efficient right? If that is the case, what you guys suggest.I mean is there any Persistent Collection Object to handle this kind of situation.
i think this was one of the reason for which data base was invented.
|
|

08-20-2008, 02:32 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
Originally Posted by DevzAbhi
i think this was one of the reason for which data base was invented.
100%. That's the best choice.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Someone helped you? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post. Help: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Resources: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Web: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Tips: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

09-09-2008, 07:15 PM
|
|
Member
|
|
Join Date: Sep 2008
Posts: 31
|
|
|
I think you should use separator between each field.Read data line by line and store according to fields using substring(). Then compares data to be modified with substring of that field.You must use separate string for each field.
You should open file in append mode.If you don't find matching string add as it is to file otherwise ad the modified data
|
|

09-10-2008, 11:15 AM
|
|
Member
|
|
Join Date: May 2008
Posts: 27
|
|
|
I m more concern about memory, not with programming. First of all , if you have 500000 records, don't have the memory to load into list. What i mean is, Serializable list .
Regards
Nanaji
|
|

09-23-2008, 03:19 PM
|
|
Member
|
|
Join Date: Aug 2008
Posts: 13
|
|
|
use StringBuffer, StringTokenizer instead of all because it is fast and full featured for this kind of work.
|
|

09-24-2008, 05:19 AM
|
|
Member
|
|
Join Date: May 2008
Posts: 27
|
|
|
String buffer stored into memory. Idea should be serialized collection.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
All times are GMT +3. The time now is 09:25 AM.
|
|
VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org