jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes please help with text formating in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "please help with text formating in java" Watch "please help with text formating in java" New topic
Author

please help with text formating in java

peter brews
Ranch Hand

Joined: Jan 25, 2002
Posts: 59
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

Joined: Jan 25, 2002
Posts: 59
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

Joined: Jan 09, 2001
Posts: 1492
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

Joined: Jan 25, 2002
Posts: 59
Manfred,
Thanks a lot for all your help

Regards,
Smita
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help with text formating in java
 
Similar Threads
Help generating JSON data - I am using FlexJSON lib
Problem~~
how to get plain text in file using print stream
Really Challenging...HelpMe..java.Util - very Urgent
MultiComponent JTable