I want to be able to read data from a csv file (comma seperated,tab seperated or space seperated) and pass the data into an array.my intentions are to combine four classes. such as a class for the data model,file reader, driver and textui. i can handle the textui and the driver but am finding it dificult with the other two classes as i am a beginner. Anyone care to help with some sample codes
abbelylee
0
Newbie Poster
Recommended Answers
Jump to PostYou need to look at how to do two things:
1) Read lines from the file. An easy way to do this is using the Scanner class.
2) Split the lines at the comma: See the String class's split() method
Jump to PostLet's assume that you are going to put the file reading code into a method, eg readDataFrom(File f). In that method all you need to to do is to read the file, split the lines (as Norm said) and add that data to a 2D array. Finally you return the …
All 6 Replies
NormR1
563
Posting Sage
Team Colleague
abbelylee
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
abbelylee
0
Newbie Poster
abbelylee
0
Newbie Poster
NormR1
563
Posting Sage
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.