の問題を抱えており、ソナーからの "FileOutputStream"を閉じます。私はファイルを閉じたのにイベント。ソナーの文書から私はエラーを理解していません。 私は投稿を見ました SONAR issue - Close this FileInputStream。 これも私の問題を解決していません。この「FileOutputStream」ソナーをもう一度閉じる
public void trainL2lSupport(String training_path, String model_path) throws Exception {
BasicConfigurator.configure();
String[] options = { "-s 1" };
FileOutputStream ms = new FileOutputStream(model_path); // This one is producing the error.
classifier.setOptions(options);
logger.info(msg + classifier.globalInfo());
loader.setFile(new File(training_path));
Instances data_set = loader.getDataSet();
data_set.setClassIndex(data_set.numAttributes() - 1);
classifier.buildClassifier(data_set);
Evaluation evaluation = new Evaluation(data_set);
evaluation.crossValidateModel(classifier, data_set, 40, new Random(1));
logger.info(evaluation.toSummaryString());
logger.info(msg1 + timer.stop());
// oos = new ObjectOutputStream(ms);
try {
ObjectOutputStream oos = new ObjectOutputStream(ms);
oos.writeObject(classifier);
oos.flush();
oos.close();
logger.info(msg3+ evaluation.toSummaryString());
logger.info(msg1 + timer.stop());
logger.info("File closed safetly");
} catch(Exception e) {
}
finally {
ms.close();
}
}
どのように解決するのですか?
オブジェクトとしてtry型の中にdeclatationを入れてください。使用前にmsが使用されていません。FileOutputStream ms = new FileOutputStream(model_path); //このエラーが発生しています。 –