Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





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.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-20-2008, 12:37 PM
Member
 
Join Date: Aug 2008
Posts: 39
hungleon88 is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-20-2008, 12:41 PM
DevzAbhi's Avatar
Member
 
Join Date: Jul 2008
Posts: 67
DevzAbhi is on a distinguished road
Store the modified records in tem.txt file ..
delete the original file ..
and rename the temp file to original name ..
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-20-2008, 12:46 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-20-2008, 01:34 PM
Member
 
Join Date: May 2008
Posts: 27
nanaji is on a distinguished road
Send a message via MSN to nanaji Send a message via Yahoo to 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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-20-2008, 02:18 PM
DevzAbhi's Avatar
Member
 
Join Date: Jul 2008
Posts: 67
DevzAbhi is on a distinguished road
Hmmmmm.
Quote:
Originally Posted by nanaji View Post
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.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-20-2008, 02:32 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by DevzAbhi View Post
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 09-09-2008, 07:15 PM
Member
 
Join Date: Sep 2008
Posts: 31
khajalid is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 09-10-2008, 11:15 AM
Member
 
Join Date: May 2008
Posts: 27
nanaji is on a distinguished road
Send a message via MSN to nanaji Send a message via Yahoo to nanaji
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
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 09-23-2008, 03:19 PM
Member
 
Join Date: Aug 2008
Posts: 13
satu is on a distinguished road
use StringBuffer, StringTokenizer instead of all because it is fast and full featured for this kind of work.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 09-24-2008, 05:19 AM
Member
 
Join Date: May 2008
Posts: 27
nanaji is on a distinguished road
Send a message via MSN to nanaji Send a message via Yahoo to nanaji
String buffer stored into memory. Idea should be serialized collection.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete From .txt file Sarinam New To Java 86 06-28-2008 12:17 PM
How to make delete particular extension file from a directory Java Tip java.io 0 04-05-2008 12:13 PM
[SOLVED] Delete Current line from file Azndaddy New To Java 1 03-28-2008 02:37 PM
problem when I try to delete a file tommy Advanced Java 2 07-31-2007 04:44 PM
How to delete a file Alpha New To Java 1 05-26-2007 10:11 AM


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