This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Reading different file extensions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Reading different file extensions" Watch "Reading different file extensions" New topic
Author

Reading different file extensions

Matthew Middleton
Greenhorn

Joined: May 05, 2004
Posts: 23
Ok, I was just wondering what all file extensions that you could read in java. I just bought a new organizer and it can import/export different files such as the to do list/schedule/phone book, but it's only for back up, I wanted to see if I could write a program to open the file and interpret the file so I could read it on my computer and maybe modify it. The files are saved as .csv. Is this possible, can i just read the file like I would a regular text file?? If not how would you do this?? Thank you for your time and GOD Bless.

Matthew Middleton
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
Yes, you can read any file in Java, you just need to know how to read it, i.e. how is the data stored in the file. File extensions do nothing magical - they just give a hint to whatever program you are using as to how to read the data. For example, if you have MS Word installed, then Windows associates .doc to Word and uses it to open that type of file.

As long as your program knows what format the data is in, then the extension can be anything. You could have files that store ascii text and use a .foobar extension. The point is - using Java, you can read any type of file; Your program just needs to know what format it's in to do anything useful, like displaying the data in a gui.

Since a .csv is normally just a comma-delimited ascii text file, then you can simply use a java.io.BufferedReader or some other character-based Reader.


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Reading different file extensions
 
Similar Threads
Where do I put these class (.class class, not class class) files?
JApplets and page source
Why J2EE is not popular in web application development?
Clarification on naming rules
Do I need my own ClassLoader? (And why?)