それで、配列に何行あるか数えようとしているのですが、やり方がわかりません。このコードを書きました。ファイルを読み取り、コンテンツを配列に入れます。配列内の行をカウントするにはどうすればよいですか?
public static void main(String[] args) throws IOException {
File file = new File("array_list.csv");
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
byte fileContent[] = new byte[(int)file.length()];
fin.read(fileContent);
String fileToArray = new String(fileContent);
//print file
System.out.println(fileToArray);
}
finally {
if (null != fin) {
fin.close();
}
}
}
ファイルarray_list.csvの内容は次のとおりです
569, 985, 97, 13,-94,256, 31, 74, 569,
-45, 601, 29, 19,-1952, 88,256,-69, 601,
1952, 1952,-15, 5,-54, 60, 89, 91, 39,
-601,-97, -6,-26, 89,-66,-601, 26, 28,
-51,-91, 39, 88, 99, 985, -7, 39,-29,
92, 1, 92, 92, 27,-11,-601, 22,-58,
13,-92, 28,-40, 27,-73, 0, 22, 33
fileToArray.length ビット explipse で試してみましたが、例外が返されます
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
length cannot be resolved or is not a field