Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class CSVRead
- {
- public static void main(String[] args)
- throws Exception
- {
- BufferedReader CSVFile =
- new BufferedReader(new FileReader("test123.csv"));
- int invalidvar = 1;
- Scanner input = new Scanner(System.in);
- System.out.println("Enter your email");
- String email =input.nextLine();
- System.out.println("Enter your password");
- String password =input.nextLine();
- String dataRow = CSVFile.readLine(); // Read first line.
- // The while checks to see if the data is null. If
- // it is, we've hit the end of the file. If not,
- // process the data.
- while (dataRow != null)
- {
- String[] dataArray = dataRow.split("\\t");
- if ((dataArray[0].equals(email))
- &&(dataArray[1].equals(password)))
- {
- System.out.println("You email is " +dataArray[0]+".");
- System.out.println("You password is " +dataArray[1]+".");
- System.out.println("You first name is " +dataArray[2]+".");
- System.out.println("You second name is " +dataArray[3]+".");
- System.out.println("You street name is " +dataArray[4]+".");
- System.out.println("You city name is " +dataArray[5]+".");
- System.out.println("You postcode is " +dataArray[6]+".");
- }
- else
- {
- System.out.println("Error");
- break;
- }
- dataRow = CSVFile.readLine();
- }
- // Close the file once all data has been read.
- CSVFile.close();
- // End the printout with a blank line.
- System.out.println();
- } //main()
- } // CSVRead
Advertisement
Add Comment
Please, Sign In to add comment