メカニズムをテストするためだけに、本当に単純なテキスト リーダーを作成しましたが、何も返されず、何もわかりません! 私はJavaの経験があまりないので、おそらく非常に単純でばかげた間違いです! コードは次のとおりです。
クラス1
import java.io.IOException;
public class display {
public static void main(String[] args)throws IOException {
String path = "C:/Test.txt";
try{
read ro = new read(path);
String[] fileData = ro.reader();
for(int i = 0; i<fileData.length;i++){
System.out.println(fileData[i]);
}
}catch(IOException e){
System.out.println("The file specified could not be found!");
}
System.exit(0);
}
}
クラス 2
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
public class read {
private String path;
public read(String file_path){
path = file_path;
}
public String[] reader() throws IOException{
FileReader fR = new FileReader(path);
BufferedReader bR = new BufferedReader(fR);
int nOL = nOLReader();
String[] textData = new String[nOL];
for(int i = 0; i < nOL; i++){
textData[i] = bR.readLine();
}
bR.close();
return textData;
}
int nOLReader()throws IOException{
FileReader fR = new FileReader(path);
BufferedReader bR = new BufferedReader(fR);
String cLine = bR.readLine();
int nOL = 0;
while(cLine != null){
nOL++;
}
bR.close();
return nOL;
}
}