It's not a secret anymore!
The moose likes Beginning Java and the fly likes Help need in reading and writing to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help need in reading and writing to a file" Watch "Help need in reading and writing to a file" New topic

Help need in reading and writing to a file

Rashid Rupani

Joined: Aug 20, 2004
Posts: 1
How to extract data from txt files and write into another txt file in a predefined format

1- Read data between "|-" and "-|"
xxxxxxx|-product a-|xxxxxxxx|- prodcut b-|xxxxx|- product c -| xxxxxx |- product d -|

2- And now write in txt file in a format defined below
product a | prodcut b | product c |

Can anyone provide me source code for this. This will help me alot.
Looking for a positive answer.
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Rashid Rupani
You may be better to do it by yourself and post any problem you may have. You can post your programming structure here if you want to improve your programming skill and learn something that you can remember by heart.
Nothing you can get if I give you an answer.

Francis Siu
omar bili
Ranch Hand

Joined: Aug 13, 2004
Posts: 177
Rahid ,you can use the FileReader and the FileWriter
to read and write Data
you can use the readLine() method
and store the Line that you have read in a String
and you can get the data from that String
if u need some help on how to use the FileWriter or
FileReader just tell me.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Rashid!

Many folks 'round here will be glad to offer advice, hints and nudges in the right direction towards you're better learning Java programming.

What have you got so far? Is something particular not clear to you? Are you getting any error messages at compile time or at run time? What are they?

When posting code, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Help need in reading and writing to a file
It's not a secret anymore!