アプリ版:「スタンプのみでお礼する」機能のリリースについて

CSVファイルをopenCSVを読み込んでその行と列の要素数の多次元配列を作りその配列にデータを格納したいです。
しかし、データが格納できません。2回目の格納するためにwhileから何かおかしいのではないかと思っています。
なにかわかる方、アドバイスが欲しいです。
public class ReadCSV {
public static void main(String[] args){
try{

CSVReader reader = new CSVReader(
new FileReader("/home/masa/Desktop/WameiSample.csv"));
//配列の宣言
String[] nextLine;

//データを配列に入れる要素数を見る
int j = 0;
nextLine = reader.readNext();
int k = nextLine.length;
System.out.println("列数[i]"+k);
System.out.println("nextLine"+nextLine);
while((nextLine = reader.readNext()) != null){
for (int i=0; i<nextLine.length; i++){
//System.out.print(nextLine[i] + "|" + i + "|");
}
//System.out.println();
j++;
}
System.out.println("行数[j]"+j);

//記憶する配列
String[][] Wamei = new String[k][j];

System.out.println("きてるよ");
//データを配列に格納していく
int x = 0;
while((nextLine = reader.readNext()) != null){
System.out.println("きてるよ");  <---こっから、表示してくれない.
for (int y=0; y<nextLine.length; y++){
Wamei[x][y] = nextLine[y];

//多次元配列の要素を表示する
System.out.print(Wamei[x][y]+"Wamei"+x+y);
}
System.out.println();
x++;
}

} catch (IOException e) {
e.printStackTrace();
}

}
}

A 回答 (1件)

最初に全部読んでるからでしょ。


もう1度最初から読み直すか、
読んだ内容をどこかに保持しておいて、それをwhileで回しなよ。
    • good
    • 0
この回答へのお礼

ありがとうございます。解決しました。

お礼日時:2011/12/06 19:12

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!