Read one line of a csv file in Java

后端 未结 6 2040
Happy的楠姐
Happy的楠姐 2021-01-21 16:59

I have a csv file that currently has 20 lines of data. The data contains employee info and is in the following format:

first name, last name, Employee ID

So one

6条回答
  •  难免孤独
    2021-01-21 17:44

    BufferedReader reader =new BufferedReader(new FileReader("yourfile.csv"));
    
            String line = "";
            while((line=reader.readLine())!=null){
                String [] employee =line.trim().split(",");
                // if you want to check either it contains some name
                //index 0 is first name, index 1 is last name, index 2 is ID
            }
    

提交回复
热议问题