How to read a particular row from excel in Java? -


i trying code program allows me retrieve details of person stored in excel file. have decided use emails way of identifying each person these unique. program not appear work, can me?

import java.io.bufferedreader; import java.io.filenotfoundexception; import java.io.filereader; import java.io.ioexception;  public class reader {      public static void main(string[] args) {          string csvfile = "clients.csv";         bufferedreader br = null;         string line = "";         string cvssplitby = ",";          try {              br = new bufferedreader(new filereader(csvfile));             while ((line = br.readline()) != null) {                 if(((br.readline().split(cvssplitby))[2]).equals("email@gmail.com")){                     string[] data = line.split(cvssplitby);                      system.out.println("first name: "+data[0]+" last name: "+data[1]+" activity level: "+data[7]);                  }              }          } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } {             if (br != null) {                 try {                     br.close();                 } catch (ioexception e) {                     e.printstacktrace();                 }             }         }      }  } 

here corrected code fixed problem:

        string csvfile = "clients.csv";         bufferedreader br = null;         string line = "";         string cvssplitby = ",";          try {              br = new bufferedreader(new filereader(csvfile));             while ((line = br.readline()) != null) {                 string[] data = line.split(cvssplitby);                 if(data[2].equals("samuelfairbrass@icloud.com")){                       system.out.println("first name: "+data[0]+" last name: "+data[1]+" email: "+data[2]+" phone number: "+data[3]+" activity level: "+data[7]);                  }               }          } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } {             if (br != null) {                 try {                     br.close();                 } catch (ioexception e) {                     e.printstacktrace();                 }             }         } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -