public final boolean loadFrom(File source) { if (source == null) { throw new IllegalArgumentException( "The file must not be null in order to load the reflected!"); } if (source.exists()) { I in = null; try { in = getCodec().newInput(source); this.loadFrom(in); } catch (IOException e) { throw new IllegalArgumentException("File to load from cannot be accessed!", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { Reflector.LOGGER.log(WARNING, "Failed to close the input stream!", e); } } } this.onLoaded(source); return true; } LOGGER.log(Level.INFO, "Could not load reflected from file! Using default..."); return false; }
public final void save(File target) { if (target == null) { throw new IllegalArgumentException("A reflected cannot be saved without a valid file!"); } O os = null; try { os = getCodec().newOutput(target); this.save(os); this.onSaved(target); } catch (IOException e) { throw new InvalidReflectedObjectException("File to save into cannot be accessed!", e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { Reflector.LOGGER.log(WARNING, "Failed to close the output stream", e); } } } }