Results 1 to 2 of 2
Thread: Loading a CSV into an array.
- 02-08-2012, 09:35 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 25
- Rep Power
- 0
Loading a CSV into an array.
I want to read my csv and then check a users login details with the csv to see if there login is valid. I am able to read the csv but how do I search through the array to check the user's inputted data with the data in the csv?
This is my code at the moment :
ThanksJava Code:public void RFile() throws IOException { File generateCSVFile = new File("test.csv"); String f = "test.csv"; if(!generateCSVFile.exists()){ System.out.println("File does not exist, Please Register"); } try { BufferedReader out = new BufferedReader(new FileReader(f)); String strLine = null; StringTokenizer st = null; int lineNumber = 0, tokenNumber = 0; while( (f = out.readLine()) != null) { lineNumber++; //break comma separated line using "," st = new StringTokenizer(f, ","); while(st.hasMoreTokens()) { //display csv values tokenNumber++; System.out.println("Line # " + lineNumber + ", Token # " + tokenNumber + ", Token : "+ st.nextToken()); } //reset token number tokenNumber = 0; } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
- 02-09-2012, 02:02 AM #2
Similar Threads
-
Loading images from an Array
By pinkette in forum New To JavaReplies: 5Last Post: 04-15-2011, 11:37 AM -
Saving from, and loading to an array.
By VisionIncision in forum New To JavaReplies: 4Last Post: 11-23-2010, 09:47 AM -
Loading jpegs into an array.
By mzatanoskas in forum New To JavaReplies: 3Last Post: 02-10-2009, 02:01 PM -
Why is one applet loading but the other isn’t?
By spmchugh82 in forum Java AppletsReplies: 1Last Post: 01-26-2009, 03:39 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks