| View previous topic :: View next topic |
| Author |
Message |
Eun Guest
|
Posted: Tue Oct 14, 2003 9:29 pm Post subject: How can I change data in a file? |
|
|
Hi.
I have a file "test.txt" with data below;
--------------------
LB = 0.1500000
OPP = 30.00000
MAX = 40.00000
------------------------------
I want to change the numbers and save the file.
Can anyone please let me know what I should do?
Thanks.
|
|
| Back to top |
|
 |
Paul Furbacher [TeamB] Guest
|
Posted: Wed Oct 15, 2003 4:22 am Post subject: Re: How can I change data in a file? |
|
|
In <3f8c6a8e$1 (AT) newsgroups (DOT) borland.com> Eun wrote:
| Quote: | I have a file "test.txt" with data below;
--------------------
LB = 0.1500000
OPP = 30.00000
MAX = 40.00000
------------------------------
I want to change the numbers and save the file.
|
Adrian provided one way of solving your problem (see
parallel response).
However, if you are open to changing the file extension
from .txt to .properties, you could use the java.util.Properties
class to handle this very easily.
Paul Furbacher [TeamB]
Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
|
|
| Back to top |
|
 |
Valentino Kyriakides Guest
|
Posted: Wed Oct 15, 2003 10:17 am Post subject: Re: How can I change data in a file? |
|
|
"Eun" <gte521w (AT) prism (DOT) gatech.edu> schrieb im Newsbeitrag
news:3f8c6a8e$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi.
I have a file "test.txt" with data below;
--------------------
LB = 0.1500000
OPP = 30.00000
MAX = 40.00000
------------------------------
I want to change the numbers and save the file.
Can anyone please let me know what I should do?
|
There are many different approaches available to handle this. Beside those
Adrian and Paul told you, you could for example read in and write out your
data also in a tab delimited format, as most spreadsheets and databases
would also support. Instead you could also write out and read in your data
in a well formed XML format etc. etc.
However, as Paul said, the easiest would really be to make use of Java's
Properties class to handle this and in case you don't like to have those
".properties" extensions, take one of those java based INI read/write file
examples and set it up in a way to work on your ".txt" extension. As an
example see:
http://www.codeguru.com/java/articles/655.shtml
http://www.geocities.com/Area51/9851/INIFiles.html
....and so on...
You can find a lot of similar and even more advanced such java based INI
read/write examples on the internet.
-Valentino
|
|
| Back to top |
|
 |
Eun Guest
|
Posted: Wed Oct 15, 2003 5:28 pm Post subject: Thanks a lot! |
|
|
I just got the job done.
Appreciate it.
- Eun
|
|
| Back to top |
|
 |
|