↓
OpenCsv「CSVReaderクラス」
http://opencsv.sourceforge.net/
【ExcelのCSV仕様】
エンクォート文字(")で囲まれた区切り文字(,)および改行はスキップします。
また、項目中のエンクォート文字(")の連続2個("")は、エンクォート文字1個(")に置き換えられます。
具体例:
47201,"900 ","900,""0000"
というデータは、
[47201] [900 ] [900,"0000]
のように分割されます。
【使用例】
import java.io.FileReader;
public class CsvFileReadSkeleton {
public static void main(String[] args) throws Exception {
CSVReader reader = new CSVReader(new FileReader("c:\\okinawa.csv"));
String [] nextLine;
int i=1;
while ((nextLine = reader.readNext()) != null) {
// nextLine[] is an array of values from the line
System.out.println("Row Number => " + i);
for( String data : nextLine ) {
System.out.println("[" + data + "]");
}
i++;
}
}
}