`

基于opencsv读取csv文件

 
阅读更多

 

 

CSVReader reader = new CSVReader(new FileReader("d://cvs/163.csv"));
        //List<String[]> list = reader.readAll() ;
        String [] nextLine;
        while ((nextLine = reader.readNext()) != null) {
        	//读一行
            System.out.println("Name: ["+nextLine[0]+"] Address: ["+nextLine[1]+"] ");
            //Email: ["+nextLine[2]+"]
        }
        reader.close();
        CSVReader reader2 = new CSVReader(new FileReader("d://cvs/163.csv"));
        List list= reader2.readAll();
        for (int j = 0; j < list.size(); j++) {
        	//读全部
        	String [] nextLine2=(String[]) list.get(j);
        	System.out.println(nextLine2[0]+"-name:"+nextLine2[1]+":email");
		}
        
 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics