Two Laptop Bag
The moose likes I/O and Streams and the fly likes Most portable format for data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Most portable format for data" Watch "Most portable format for data" New topic

Most portable format for data

Emilio Gagliardi

Joined: Jun 02, 2004
Posts: 16
Hi just a quick question, what is the best way to store primitive types when writing to a file so that other programs can read/import the data? For example, excel or SPSS.


Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

For Excel, a comma delimitted file is best.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

spss handles csv-files too.
Emilio Gagliardi

Joined: Jun 02, 2004
Posts: 16
This is probably a dumb question but are CSV files written as char?
As in, if I want to store 123456 as an actual integer it would take 4 bytes, as opposed to 12 bytes to store the six that right? If so, then I must write the numbers and commas and end-of-line characters.

Thank you for your input. =)

Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
Why not create a file in Excel and see how it saves it? You'll find, I think, that ultimately you have to write numbers in human-readable format. So I'd be going with a PrintWriter.

Richard Rodger

Joined: Jan 07, 2005
Posts: 17
CSV files are in a plain text human-readable format, so you would output all 6 characters.

Richard Rodger<br /><a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Most portable format for data
It's not a secret anymore!