• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help need in reading and writing to a file

 
Rashid Rupani
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to extract data from txt files and write into another txt file in a predefined format


Example
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
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rashid Rupani
welcome
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.
 
omar bili
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic