テキストファイルを文字列変数に読み込もうとしています。テキスト ファイルには複数の行があります。「読み取り」コードをテストするために文字列を出力すると、すべての文字の間に追加のスペースがあります。String を使用して文字バイグラムを生成しているため、スペースによってサンプル テキストが役に立たなくなります。コードは
try {
FileInputStream fstream = new FileInputStream(textfile);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
//Read corpus file line-by-line, concatenating each line to the String "corpus"
while ((strLine = br.readLine()) != null) {
corpus = (corpus.concat(strLine));
}
in.close(); //Close the input stream
}
catch (Exception e) { //Catch exception if any
System.err.println("Error test check: " + e.getMessage());
}
アドバイスをいただければ幸いです。
ありがとう。