Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help with text formating in java

 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The input file format is :
key1[0]| aaaaa |
|bbbb |
|ffff |
|ggggg |

key2[0]|ccccc |
|qqqqq |
|dddddd |

I need to read this data from text file and output should be following xml format:
<root>
<row>
<key1>aaaaa</key1>
<key2>ccccc</key2>
</row>
<row>
<key1>bbbb</key1>
<key2>qqqqq</key2>
</row>
<row>
<key1>ffff</key1>
<key2>ddddd</key2>
</row>
<row>
<key1>gggg</key1>
<key2></key2>
</row>
Please advise what will be the best way to get this output.
Thanks for all your help
smita
 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so far I have wrote this:

I would appreciate if any body can advise how to proceed next to get desired output
[ January 28, 2002: Message edited by: Cindy Glass ]
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Smita,
I would break up the reading and writing so that you have a known format when you get to the writer. Unless the input file is huge and memory is low the approach below should work.

Enjoy,
Manfred.
 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manfred,
Thanks a lot for all your help

Regards,
Smita
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic