editing file

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2008
Posts: 13
Reputation: nouryn is an unknown quantity at this point 
Solved Threads: 0
nouryn nouryn is offline Offline
Newbie Poster

editing file

 
0
  #1
Nov 23rd, 2008
Hi,I need to edit in a file without deleting all the data.
Thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,197
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: editing file

 
-1
  #2
Nov 23rd, 2008
As I do not know which exactly writer you using only thing I can say is to look for append() method which will be either directly implemented in used writer class or inherited from other classes above this one
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: editing file

 
0
  #3
Nov 23rd, 2008
Originally Posted by nouryn View Post
Hi,I need to edit in a file without deleting all the data.
Thanks
do you need to edit the data in a file, append data, delete parts of the file (without deleting ALL of the data, as you put it), ...

anyway, open notepad, type something, close and save it.
re-open the file, add a line, press 'ctrl+s' and your job is done.

don't need to thank me, the bill 'll come later

if your task is to create an application that does such, start writing code, begin with the easy parts, and come back here when you get stuck.

when you do so, post the relevant code, post what it should do, post what it is doing, post any error messages and whatever you think WE think might be relevant
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 13
Reputation: nouryn is an unknown quantity at this point 
Solved Threads: 0
nouryn nouryn is offline Offline
Newbie Poster

Re: editing file

 
0
  #4
Nov 23rd, 2008
first i know how to open a file and write in it and save it I'm not gonna waste my time for such a thing.second my problem is i write to the file customer data and then the customer can edit it so i want to edit this data in the file (adding the new one and deleting the old data)I opened a temp file but it's not working can i do it without temp files?how?.
Thanks
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: editing file

 
0
  #5
Nov 24th, 2008
Originally Posted by nouryn View Post
first i know how to open a file and write in it and save it I'm not gonna waste my time for such a thing.second my problem is i write to the file customer data and then the customer can edit it so i want to edit this data in the file (adding the new one and deleting the old data)I opened a temp file but it's not working can i do it without temp files?how?.
Thanks
when you want to change data in a txt file (manually) do you first create a temp file? no, so why would this be different?
just overwrite what you want to change
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,197
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: editing file

 
-1
  #6
Nov 24th, 2008
@nouryn - if you can provide better description of user editing process we may able to help. However right now as you can see from the responses it is not clear what you try to do. Some supporting coding would be welcome...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,677
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 226
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: editing file

 
0
  #7
Nov 24th, 2008
Are you familiar with the 'append' argument of the FileWriter ?

  1. BufferedWriter writer= new BufferedWriter(new FileWriter(file, true));

When you try to write to the file, the new data will be appended after the existing
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 13
Reputation: nouryn is an unknown quantity at this point 
Solved Threads: 0
nouryn nouryn is offline Offline
Newbie Poster

Re: editing file

 
0
  #8
Nov 24th, 2008
hi,sorry that i didn't describe my program clear enough.
i have a file contain the following
123 Nouryn current =5000
124 Jasmine investment =300

the customer want to add to his account 300 so i search for his name and then search for ("=")so he take the credit and store it so the customer can add on it.
the user want to add 300 so the new credit will be 5300 this data must be written in the file but after deleting the old one how to do it.

now i;m trying to put the new data and the old ones in a new file but only the data after the edited line is written:s.i've attach my code hope i explained well this time.
help plllllllllllllllzzzzzzzzzzzzzz
Attached Files
File Type: java DeleteFile2.java (1.3 KB, 1 views)
File Type: java SearchFile.java (4.3 KB, 2 views)
File Type: java OldCustomer.java (4.2 KB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,677
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 226
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: editing file

 
0
  #9
Nov 24th, 2008
A simple way to do it is read the entire file and store its data somewhere (for example a Vector). Then change the credit in the Vector, after you find the right element, and save the Vector with the new data back to the file
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 13
Reputation: nouryn is an unknown quantity at this point 
Solved Threads: 0
nouryn nouryn is offline Offline
Newbie Poster

Re: editing file

 
0
  #10
Nov 24th, 2008
sorry but i don't know how to use vectors.can i do it with a different way??
Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC