Results 1 to 2 of 2
  1. #1
    OllyHal is offline Member
    Join Date
    Feb 2012
    Posts
    25
    Rep Power
    0

    Default 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 :
    Java 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();
    	}
    }
    Thanks

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Loading a CSV into an array.

    how do I search through the array to check the user's inputted data with the data in the csv
    Normally you use a loop to go through the elements in an array.

Similar Threads

  1. Loading images from an Array
    By pinkette in forum New To Java
    Replies: 5
    Last Post: 04-15-2011, 11:37 AM
  2. Saving from, and loading to an array.
    By VisionIncision in forum New To Java
    Replies: 4
    Last Post: 11-23-2010, 09:47 AM
  3. Loading jpegs into an array.
    By mzatanoskas in forum New To Java
    Replies: 3
    Last Post: 02-10-2009, 02:01 PM
  4. Why is one applet loading but the other isnít?
    By spmchugh82 in forum Java Applets
    Replies: 1
    Last Post: 01-26-2009, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •