Solved

Java library to read write XML/ text file

Posted on 2010-09-23
6
515 Views
Last Modified: 2013-11-23
Hello,

Looking for a library to read text files and write to XML (incl. XML to Text).

Downloaded JDOM to take care of creating  the XML.    Can Apache POI be used to read / write the text files?

Written unformatted data to text files in the past using FileReader/FileWriter, not sure how to control the formatting of the text file the same way ApachePOI supports writing to CSV etc.

Any other libraries available?

An example:

#----------------------------------------------------------------
"hr"              ! Units
14              ! Entries
"4"              ! No of Columns
#----------------------------------------------------------------

 ID           Parameter     LowBound      UpBound        
Para1     abc                10                     20            


Thanks.
0
Comment
Question by:AndyC1000
6 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 33751510
use openCSV to read/write csv format. use JAXB to read write xml data, the advantage of using both is you can deal with bean in application represnting each record in CSV/XML
0
 
LVL 92

Expert Comment

by:objects
ID: 33751561
0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 500 total points
ID: 33751934
Another thing you should take a look at is Apache Camel
http://en.wikipedia.org/wiki/Apache_Camel
http://camel.apache.org/

Camel is a framework for allowing integration of a lot of remote systems. For this it has adapters to read and write a wide variety  of formats and to describe the flow of information from a source to a destination. Here's an example of how to read a CSV:
http://camel.apache.org/csv.html
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:AndyC1000
ID: 33766682
I need to read .xml and write to .txt (and vice versa).

I've looked into your links - is there an easy way to convert from .csv to .txt?
0
 

Author Comment

by:AndyC1000
ID: 33766787
Ignore the above post.

I've just worked out that I'll need to look into if the libraries write to tab seperated value file.
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33779162
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now