I want to save the BoundedPropagator object to the hard disk after java serialization, but now it can’t be saved when serialization. Is there a good solution?
public static BoundedPropagator getEphemeris() {
Path path = Paths.get("d:/", "config.data");
if (Files.exists(path)) {
try (ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(path))) {
BoundedPropagatorBO boundedPropagatorBO = (BoundedPropagatorBO) objectInputStream.readObject();
return boundedPropagatorBO.getGeneratedEphemeris();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
return null;
}
public static void saveEphemeris(BoundedPropagator generatedEphemeris) {
Path path = Paths.get("d:/", "config.data");
if (!Files.exists(path)) {
try {
Files.createFile(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(path))) {
objectOutputStream.writeObject(new BoundedPropagatorBO(generatedEphemeris));
} catch (IOException e) {
throw new RuntimeException(e);
}
}