Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2004, 10:31 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading a CVS file

I am writing a application which would read a CVS file and should output array of objects. Can anybody help me to solve this problem and give me guidelines.

Regards
PRT
 
Old September 7th, 2004, 11:14 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I'm assuming you meant CSV file, and weren't thinking of CVS https://www.cvshome.org/docs/manual/ , which is a source code control system.

You can do this quite simply, though it does depend on whether each line represents a discrete object or each field does.

1. for each line in your CSV file parse out the fields ( a stringtokenizer object will help you do this quite nicely) then EITHER

2a. instantiate an object based on those fields and add it to the array or a java.util.Vector

2b. instantiate a new object for each of the fields from that line, and add the object to your array or Vector.

Handy classes to read about would be StringTokenizer, Vector, and the StreamReader classes.

--
Don't Stand on your head - you'll get footprints in your hair. http://charlieharvey.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP file reading XML file for output rydog65 Beginning PHP 0 March 26th, 2008 05:13 PM
Update file from CVS using Nant tool jilly BOOK: ASP.NET Website Programming Problem-Design-Solution 1 May 31st, 2006 08:09 PM
Import dat from cvs or xls file into dataset briisek C# 2 September 9th, 2005 11:05 AM
Uploaded a cvs file via phpMyAdmin from a PocketPC bourdett PHP How-To 0 January 8th, 2005 12:19 PM
reading HTML from file -> write to file mikeuk Beginning PHP 4 July 21st, 2004 05:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.