package utils;
import java.nio.charset.Charset;
import java.util.ArrayList;
import com.csvreader.CsvReader;
/**********************csv读取*******************************/
public class ReadCSv {
public ArrayList Readcsv(String ulr){
ArrayList<String[]> csvList = new ArrayList<String[]>();
try {
String csvFilePath = ulr;
CsvReader reader = new CsvReader(csvFilePath,',',Charset.forName("gbk"));
reader.readHeaders(); // 跳过表头
System.out.println("开始");
while(reader.readRecord()){
csvList.add(reader.getValues());
}
reader.close();
// for(int row=0;row<csvList.size();row++){
// String s=csvList.get(row)[1];
// }
System.out.println("结束");
}catch(Exception ex){
System.out.println(ex);
}
finally{
return csvList;
}
}
/* public static void main(String[] arge){
ArrayList<String[]> a = new ArrayList<String[]>();
a=Readcsv("csvFile\\csv.csv");
for(int row=0;row<a.size();row++){
String s=a.get(row)[0];
System.out.println(s);
}
}*/
}
jar资源下载:http://download.csdn.net/detail/xiaoaiqi/9632172