Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hi, Can java create a .csv file

Status
Not open for further replies.

iamshailu

Programmer
Feb 5, 2003
12
IN
hi,
Can java create a .csv file if Excel or MS Project file name is given as input.

Thanks,
Shailaja.
 
hi,
can POI read and write MS Project 98 .MPP files. As I am new to this project, can u please help me with sample code, to read from MS Project 98.

Thanks,
Shailaja.
 
A .csv file is merely a text file that contains Comma Seperated Values. So you could easily create this file just as simply as you would create any other text file.
I'm not entirely sure how POI would help, as I have never used it before, but you could use a standard file stream to write to the file in question or read from it. As long as you know what each position stands for and place the correct number of commas seperated values per line than any program that can read csv files should understand it.
Another option here is to use XML, as it is a more understandable way to store flat text data. Having used both with Java I would tend to go the XML direction, as the parsers are already built if you need to get the information back out of the file and they are optimized enough to be extremely quick.

-Tarwn ________________________________________________
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Hey there sorry to bump in like that. Tarwn, would you have a simple working example of an XML file being written and read through Java? Thanks in advance even a link to a tutorial would do. Gary Haran
 
The java web services tutorial is pretty good at and more specifically at It is fairly heavy going if you are trying to do this really quickly. There is sample code though.

Also IBM's developer works and alpha works sites are really good in general and more specifically at
which is an introduction to xml processing using java with sample code. There is a zip file of code a few pages into the DOM chapter3. You do have to register though. The IBM sites are well worth checking out.
 
java.io.File f = new java.io.File("myfile.xml");

org.w3c.dom.Document mydoc = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f);

The dom does not provide specific "save to file" methods outside of XSLT transformations.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top