CSVファイルを読み取るにはストリームオブジェクトが必要です。
FileInputStream fis = new FileInputStream("FileName.CSV");
BufferedInputStream bis = new BufferedInputStream(fis); InputStreamReader isr = new InputStreamReader(bis);
inputstreamオブジェクトを読み取り、ファイルをStringオブジェクトに格納します。
次に、区切り文字として[comma]を指定してStringTokenizerを使用します->トークンを取得しますトークンを操作して値を取得してください。
String str = "This is String , split by StringTokenizer, created by mkyong";
StringTokenizer st = new StringTokenizer(str);
System.out.println("---- Split by space ------");
while (st.hasMoreElements()) {
System.out.println(st.nextElement());
}
System.out.println("---- Split by comma ',' ------");
StringTokenizer st2 = new StringTokenizer(str, ",");
while (st2.hasMoreElements()) {
System.out.println(st2.nextElement());
}
ありがとう、
パヴァン