/** * Reads the state of this object during deserialization. * * @param aOIS * The stream from which the state should be read. * @throws IOException * if an error occurs. * @throws ClassNotFoundException * if class cannot be found. */ private void readObject (@Nonnull final ObjectInputStream aOIS) throws IOException, ClassNotFoundException { // read values aOIS.defaultReadObject (); try (final OutputStream aOS = getOutputStream ()) { if (m_aCachedContent != null) { aOS.write (m_aCachedContent); } else { final InputStream aIS = FileHelper.getInputStream (m_aDFOSFile); StreamHelper.copyInputStreamToOutputStream (aIS, aOS); FileOperations.deleteFile (m_aDFOSFile); m_aDFOSFile = null; } } m_aCachedContent = null; }
/** * Removes the file contents from the temporary storage. * * @throws Throwable * as declared by super.finalize() */ @Override protected void finalize () throws Throwable { FileOperations.deleteFileIfExisting (m_aDFOS.getFile ()); super.finalize (); }
if (FileOperations.renameFile (aOutputFile, aDstFile).isSuccess ()) return ESuccess.SUCCESS; return FileOperations.copyFile (aOutputFile, aDstFile);
if (FileOperations.createDirIfNotExisting (aSVRLFile.getParentFile ()).isFailure ()) log ("Failed to create parent directory of '" + aSVRLFile.getAbsolutePath () + "'!", Project.MSG_ERR);
/** * Deletes the underlying storage for a file item, including deleting any * associated temporary disk file. Although this storage will be deleted * automatically when the <code>FileItem</code> instance is garbage collected, * this method can be used to ensure that this is done at an earlier time, * thus preserving system resources. */ public void delete () { m_aCachedContent = null; final File aTempFile = getStoreLocation (); if (aTempFile != null) { final FileIOError aIOError = FileOperations.deleteFileIfExisting (aTempFile); if (aIOError.isFailure ()) if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to delete temporary file " + aTempFile + " with error " + aIOError.toString ()); } }
public void deleteAllTemporaryFiles () { final ICommonsList <File> aTempFiles = m_aRWLock.writeLocked ( () -> { final ICommonsList <File> ret = m_aTempFiles.getClone (); m_aTempFiles.clear (); return ret; }); for (final File aTempFile : aTempFiles) { final FileIOError aIOError = FileOperations.deleteFileIfExisting (aTempFile); if (aIOError.isFailure ()) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to delete temporary file " + aTempFile + " with error " + aIOError.toString ()); _addTempFile (aTempFile); } } } }