public class ArchiveUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FILE_EXTENSION
To support file/folder with same name, use the FILE_EXTENSION for files.
|
static char |
UNIX_SEPARATOR_CHAR |
static java.lang.String |
UNIX_SEPERATOR |
Constructor and Description |
---|
ArchiveUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
archive(java.lang.String folderName,
IStreamSorter sorter,
java.lang.String fileName)
Compound File Format:
1long(stream section position) + 1long(entry number in lookup map) + lookup map section + stream data section The Lookup map is a hash map. |
static void |
archive(java.lang.String folderName,
IStreamSorter sorter,
java.lang.String fileName,
boolean contentEscape)
Compound File Format:
1long(stream section position) + 1long(entry number in lookup map) + lookup map section + stream data section The Lookup map is a hash map. |
static void |
archive(java.lang.String folder,
java.lang.String file) |
static int |
bytesToInteger(byte[] b)
Assemble four bytes to an int value, make sure that the passed bytes
length is larger than 4.
|
static int |
bytesToInteger(byte[] b,
int off) |
static long |
bytesToLong(byte[] b)
Assemble eight bytes to an long value, make sure that the passed bytes
length larger than 8.
|
static long |
bytesToLong(byte[] b,
int off) |
static void |
convertFolderArchive(java.lang.String folder,
java.lang.String file) |
static void |
copy(IArchiveFile inArchive,
IArchiveFile outArchive) |
static void |
copy(IArchiveFile inArchive,
IArchiveFile outArchive,
java.util.Map<java.lang.String,java.lang.String> transformations) |
static void |
copy(IDocArchiveReader reader,
IDocArchiveWriter writer) |
static void |
copy(IDocArchiveReader reader,
IDocArchiveWriter writer,
java.util.Map<java.lang.String,java.lang.String> transformations) |
static void |
createParentFolder(java.io.File fd)
If the parent folder of the file doesn't exsit, create the parent folder.
|
static IDocArchiveReader |
createReader(IDocArchiveWriter writer) |
static void |
deleteAllFiles(java.io.File dirOrFile)
Recursively delete all the files and folders under dirOrFile
|
static void |
expand(java.lang.String file,
java.lang.String folder) |
static java.lang.String |
generateUniqueFileFolderName(java.lang.String originalName)
Generate a unique file or folder name which is in the same folder as the
originalName
|
static java.lang.String |
getEntryName(java.lang.String filePath)
escape entry name to a valid file name
|
static java.lang.String |
getEntryName(java.lang.String rootPath,
java.lang.String fullPath)
convert a folder to entry name.
|
static java.lang.String |
getFilePath(java.lang.String entryName)
escape entry name to a valid file path
duplicate '/' will be removed
|
static java.lang.String |
getFilePath(java.lang.String rootPath,
java.lang.String entryName) |
static java.lang.String |
getFolderPath(java.lang.String rootPath,
java.lang.String entryName) |
static java.lang.String |
getFullPath(java.lang.String root,
java.lang.String relative) |
static java.lang.String |
getRelativePath(java.lang.String rootPath,
java.lang.String fullPath) |
static void |
integerToBytes(int v,
byte[] b) |
static void |
integerToBytes(int v,
byte[] b,
int off) |
static void |
listAllFiles(java.io.File dir,
java.util.ArrayList<? super java.io.File> fileList)
Get all the files under the specified folder (including all the files
under sub-folders)
|
static void |
longToBytes(long v,
byte[] b) |
static void |
longToBytes(long v,
byte[] b,
int off) |
static boolean |
removeFileAndFolder(java.io.File file) |
static java.lang.String[] |
split(java.lang.String value,
char splitChar)
split strings by the character.
|
static void |
unzipArchive(java.io.File zipArchive,
java.lang.String tempFolderPath) |
static void |
zipFolderToStream(java.lang.String tempFolderPath,
java.io.OutputStream ostream) |
public static final char UNIX_SEPARATOR_CHAR
public static final java.lang.String UNIX_SEPERATOR
public static final java.lang.String FILE_EXTENSION
public static java.lang.String getFolderPath(java.lang.String rootPath, java.lang.String entryName)
rootPath
- - the absolute path of the root folder.relativePath
- - the relative path.public static java.lang.String getFilePath(java.lang.String rootPath, java.lang.String entryName)
public static java.lang.String getFullPath(java.lang.String root, java.lang.String relative)
root
- use unix path separatorrelative
- use unix path separatorpublic static java.lang.String[] split(java.lang.String value, char splitChar)
value
- splitChar
- public static java.lang.String getFilePath(java.lang.String entryName)
name
- public static java.lang.String getEntryName(java.lang.String filePath)
filePath
- , a relative file path, start with "/"public static java.lang.String getEntryName(java.lang.String rootPath, java.lang.String fullPath)
rootPath
- -
the absolute path of the root folder. The path is seperated by
system's File seperator.fullString
- -
the absolute path of the stream. The path is seperated by
system's File seperator.public static java.lang.String getRelativePath(java.lang.String rootPath, java.lang.String fullPath)
public static java.lang.String generateUniqueFileFolderName(java.lang.String originalName)
originalName
- -
the original Name. For example, it could be the name of the
file archivepublic static void createParentFolder(java.io.File fd)
public static void deleteAllFiles(java.io.File dirOrFile)
dirOrFile
- -
the File object which could be either a folder or a file.public static void zipFolderToStream(java.lang.String tempFolderPath, java.io.OutputStream ostream)
public static void unzipArchive(java.io.File zipArchive, java.lang.String tempFolderPath)
public static void copy(IArchiveFile inArchive, IArchiveFile outArchive) throws java.io.IOException
java.io.IOException
public static void copy(IArchiveFile inArchive, IArchiveFile outArchive, java.util.Map<java.lang.String,java.lang.String> transformations) throws java.io.IOException
inArchive
- Source ArchiveoutArchive
- Destination Archivetransformations
- Optional transformations of streams specified via java regex patterns.
The map is keyed in by a regex pattern and the value will be the replacement expression which may refer
capturing groups in the key. While copying the streams, if any of the key regex patterns matches the current source stream path
being copied, the replacement expression is used to transform the source stream path to a target stream path.java.io.IOException
public static void copy(IDocArchiveReader reader, IDocArchiveWriter writer) throws java.io.IOException
java.io.IOException
public static void copy(IDocArchiveReader reader, IDocArchiveWriter writer, java.util.Map<java.lang.String,java.lang.String> transformations) throws java.io.IOException
reader
- Sourcewriter
- Destinationtransformations
- Optional Stream Transformations specified using Java regex patternsjava.io.IOException
public static void archive(java.lang.String folder, java.lang.String file) throws java.io.IOException
java.io.IOException
public static void convertFolderArchive(java.lang.String folder, java.lang.String file) throws java.io.IOException
java.io.IOException
public static void archive(java.lang.String folderName, IStreamSorter sorter, java.lang.String fileName) throws java.io.IOException
tempFolder
- fileArchiveName
- -
the file archive namejava.io.IOException
public static void archive(java.lang.String folderName, IStreamSorter sorter, java.lang.String fileName, boolean contentEscape) throws java.io.IOException
tempFolder
- fileArchiveName
- -
the file archive namejava.io.IOException
public static void listAllFiles(java.io.File dir, java.util.ArrayList<? super java.io.File> fileList)
dir
- -
the folder to look intofileList
- -
the fileList to be returnedpublic static void expand(java.lang.String file, java.lang.String folder) throws java.io.IOException
java.io.IOException
public static final int bytesToInteger(byte[] b)
bytes
- public static final int bytesToInteger(byte[] b, int off)
public static final long bytesToLong(byte[] b)
bytes
- public static final long bytesToLong(byte[] b, int off)
public static final void integerToBytes(int v, byte[] b)
public static final void integerToBytes(int v, byte[] b, int off)
public static final void longToBytes(long v, byte[] b)
public static final void longToBytes(long v, byte[] b, int off)
public static boolean removeFileAndFolder(java.io.File file)
public static final IDocArchiveReader createReader(IDocArchiveWriter writer)
Copyright © 2008 Actuate Corp. All rights reserved.