もちろん、ファイルから入力を読み取り、何らかの処理後に別のファイルに書き込むコードを書いています。さて、私の入力ファイルは、
4
0 1
0 2
0
0 3
3
0
0
0
E
私がする必要があるのは、左側の要素を最初の列の配列にコピーし、右側の要素を2番目の列にコピーすることです。スキャナーを使用しましたが、行末を認識しません。助けて!!!!これは私が試したものです。行をコピーしてから変更してみました。
for (i = 0; i < size; i++) {
if (!f1.hasNext(endPage)) {
String temp1 = f1.next();
String temp2 = f1.next();
int a[] = new int[4];
a[0] = (int) temp1.charAt(temp1.length() - 1);
a[1] = (int) temp2.charAt(temp1.length() - 1);
a[2] = (int) temp1.charAt(temp1.length() - 2);
a[3] = (int) temp1.charAt(temp1.length() - 2);
scales[i].weightOnLeft = a[0];
scales[i].weightOnRight = a[1];
scales[i].left = scales[a[2]];
scales[i].right = scales[a[3]];
}
}