Package de.intarsys.tools.file
Class ArchiveTools
- java.lang.Object
-
- de.intarsys.tools.file.ArchiveTools
-
public class ArchiveTools extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ArchiveTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringarchive(java.io.File root, java.lang.String relativePath, java.io.File file, int max, java.lang.String sourceEncoding, java.lang.String destinationEncoding, boolean deleteSource, boolean forceArchive)Archive a files content.static java.lang.Stringarchive(java.io.File root, java.lang.String relativePath, java.lang.String filename, java.io.InputStream is, int max)Create a archive file and dump the input stream to this file.static java.io.FilecreateArchive(java.io.File root, java.lang.String relativePath, java.lang.String filename, int max)Just creates a archive file, nothing will be dumped inside this file.static java.io.OutputStreamcreateOutputStream(java.io.File root, java.lang.String filename, int max)
-
-
-
Method Detail
-
archive
public static java.lang.String archive(java.io.File root, java.lang.String relativePath, java.io.File file, int max, java.lang.String sourceEncoding, java.lang.String destinationEncoding, boolean deleteSource, boolean forceArchive) throws java.io.IOExceptionArchive a files content.The method creates a copy in the archive directory with a unique name that is guaranteed to create a sortable representation so that newer files have a "greater" filename. Creation of file names is thread safe. If more than
maxfiles are in the archive directory, the oldest files are deleted. max = 0 means never create archive, max = -1 means always create archive. IfdeleteSourceistrue, the file to be archived is deleted after the archive was created.- Parameters:
root- The root for relative addressing.relativePath- The path relative to root where to create the archive.file- The file to archive.max- The maximum number of archive files allowed.hansourceEncoding- The encoding of the file to be archived.destinationEncoding- The encoding of the archived file.deleteSource- Flag if source should be deleted.forceArchive- Flag if we should archive even if file is already in the archive directory.- Returns:
- The name of the archived file, or null.
- Throws:
java.io.IOException
-
archive
public static java.lang.String archive(java.io.File root, java.lang.String relativePath, java.lang.String filename, java.io.InputStream is, int max) throws java.io.IOExceptionCreate a archive file and dump the input stream to this file. Calls createArchive, and then copies the is to the output stream.- Parameters:
root- The root for relative addressing.relativePath- The path relative to root where to create the archive.filename- The file to archive.max- The maximum number of archive files allowed.hanis- The input stream to be dumped.- Returns:
- The name of the archived file, or null.
- Throws:
java.io.IOException
-
createArchive
public static java.io.File createArchive(java.io.File root, java.lang.String relativePath, java.lang.String filename, int max) throws java.io.IOExceptionJust creates a archive file, nothing will be dumped inside this file.- Parameters:
root- The root for relative addressing.relativePath- The path relative to root where to create the archive.filename- The file to archive.max- The maximum number of archive files allowed.han- Returns:
- The name of the archived file, or null.
- Throws:
java.io.IOException
-
createOutputStream
public static java.io.OutputStream createOutputStream(java.io.File root, java.lang.String filename, int max) throws java.io.IOException- Throws:
java.io.IOException
-
-