use of jp.ossc.nimbus.io.ExtentionFileFilter in project nimbus by nimbus-org.
the class CodeMasterService method load.
public void load() throws IOException, ClassNotFoundException {
if (persistDir == null) {
throw new IOException("PersistDir is null.");
}
if (master == null) {
throw new IOException("Master is not initializing.");
}
File dir = new File(persistDir);
if (!dir.exists()) {
return;
} else if (!dir.isDirectory()) {
throw new IOException("PersistDir is not directory. path=" + persistDir);
}
synchronized (master) {
File[] files = dir.listFiles(new ExtentionFileFilter(".mst"));
for (int i = 0; i < files.length; i++) {
String key = files[i].getName().substring(0, files[i].getName().lastIndexOf('.'));
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(files[i]));
try {
master.put(key, ois.readObject());
} finally {
ois.close();
}
}
}
}
Aggregations