本文整理了Java中org.fcrepo.utilities.Zip
类的一些代码示例,展示了Zip
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zip
类的具体详情如下:
包路径:org.fcrepo.utilities.Zip
类名称:Zip
[英]Zip and GZip utilities.
[中]Zip和GZip实用程序。
代码示例来源:origin: fcrepo3/fcrepo
public static void unzip(InputStream is, String destDir)
throws FileNotFoundException, IOException {
unzip(is, new File(destDir));
}
代码示例来源:origin: fcrepo3/fcrepo
/**
* Create a zip file.
*
* @param destination
* The zip file to create.
* @param source
* The file or directory to be zipped.
* @throws FileNotFoundException
* @throws IOException
*/
public static void zip(File destination, File source)
throws FileNotFoundException, IOException {
zip(destination, new File[] {source});
}
代码示例来源:origin: org.fcrepo/fcrepo-common
/**
* Create a zip file.
*
* @param destination
* The zip file to create.
* @param source
* The file or directory to be zipped.
* @throws FileNotFoundException
* @throws IOException
*/
public static void zip(File destination, File source)
throws FileNotFoundException, IOException {
zip(destination, new File[] {source});
}
代码示例来源:origin: org.fcrepo/fcrepo-common
public static void unzip(InputStream is, String destDir)
throws FileNotFoundException, IOException {
unzip(is, new File(destDir));
}
代码示例来源:origin: org.fcrepo/fcrepo-common
public static void zip(String destination, String source)
throws FileNotFoundException, IOException {
zip(new File(destination), new File(source));
}
代码示例来源:origin: fcrepo3/fcrepo
private File stage(InputStream inputStream) throws IOException {
File stagingDir = new File(installDir, "fedorawar");
stagingDir.mkdirs();
Zip.unzip(inputStream, stagingDir);
return stagingDir;
}
private File repackage(File stagingDir, File outputFile) throws IOException {
代码示例来源:origin: fcrepo3/fcrepo
public static void zip(String destination, String source)
throws FileNotFoundException, IOException {
zip(new File(destination), new File(source));
}
代码示例来源:origin: fcrepo3/fcrepo
/**
* Unpacks the contents of the FEDORA_HOME directory from the Distribution.
*
* @throws InstallationFailedException
*/
private void unpack() throws InstallationFailedException {
System.out.println("Preparing FEDORA_HOME...");
if (!_installDir.exists() && !_installDir.mkdirs()) {
throw new InstallationFailedException(
"Unable to create FEDORA_HOME: "
+ _installDir.getAbsolutePath());
}
if (!_installDir.isDirectory()) {
throw new InstallationFailedException(_installDir.getAbsolutePath()
+ " is not a directory");
}
try {
Zip.unzip(_dist.get(Distribution.FEDORA_HOME), _installDir);
setScriptsExecutable(new File(_installDir, "client"
+ File.separator + "bin"));
File serverDir = new File(_installDir, "server");
if (_clientOnlyInstall) {
FileUtils.delete(serverDir);
} else {
setScriptsExecutable(new File(serverDir, "bin"));
}
} catch (IOException e) {
throw new InstallationFailedException(e.getMessage(), e);
}
}
代码示例来源:origin: fcrepo3/fcrepo
private File repackage(File stagingDir, File outputFile) throws IOException {
Zip.zip(outputFile, stagingDir.listFiles());
FileUtils.delete(stagingDir);
return outputFile;
}
private void addLibrary(File stagingDir, String libraryPath,
代码示例来源:origin: fcrepo3/fcrepo
@Override
protected void installTomcat() throws InstallationFailedException {
System.out.println("Installing Tomcat...");
try {
Zip.unzip(getDist().get(Distribution.TOMCAT), System
.getProperty("java.io.tmpdir"));
} catch (IOException e) {
throw new InstallationFailedException(e.getMessage(), e);
}
File f =
new File(System.getProperty("java.io.tmpdir"),
Distribution.TOMCAT_BASENAME);
if (!FileUtils.move(f, getTomcatHome())) {
throw new InstallationFailedException("Move to "
+ getTomcatHome().getAbsolutePath() + " failed.");
}
FedoraHome.setScriptsExecutable(new File(getTomcatHome(), "bin"));
}
代码示例来源:origin: fcrepo3/fcrepo
/**
* Create a zip file.
*
* @param destination
* The zip file to create.
* @param source
* The File array to be zipped.
* @throws FileNotFoundException
* @throws IOException
*/
public static void zip(File destination, File[] source)
throws FileNotFoundException, IOException {
FileOutputStream dest = new FileOutputStream(destination);
ZipOutputStream zout =
new ZipOutputStream(new BufferedOutputStream(dest));
for (File element : source) {
zip(null, element, zout);
}
zout.close();
}
代码示例来源:origin: fcrepo3/fcrepo
@Test
public void testUnzip() throws Exception {
FileInputStream fis = new FileInputStream(ZIP_FILE);
Zip.unzip(fis, TMP_DIR);
FileReader fr =
new FileReader(TMP_DIR + File.separator + "foo"
+ File.separator + "foo.txt");
BufferedReader buff = new BufferedReader(fr);
boolean eof = false;
while (!eof) {
String line = buff.readLine();
if (line == null) {
eof = true;
} else {
assertEquals("foo", line);
}
}
buff.close();
}
}
代码示例来源:origin: org.fcrepo/fcrepo-common
/**
* Create a zip file.
*
* @param destination
* The zip file to create.
* @param source
* The File array to be zipped.
* @throws FileNotFoundException
* @throws IOException
*/
public static void zip(File destination, File[] source)
throws FileNotFoundException, IOException {
FileOutputStream dest = new FileOutputStream(destination);
ZipOutputStream zout =
new ZipOutputStream(new BufferedOutputStream(dest));
for (File element : source) {
zip(null, element, zout);
}
zout.close();
}
代码示例来源:origin: fcrepo3/fcrepo
File files[] = source.listFiles();
for (File element : files) {
zip(entry.getName(), element, zout);
代码示例来源:origin: org.fcrepo/fcrepo-common
File files[] = source.listFiles();
for (File element : files) {
zip(entry.getName(), element, zout);
代码示例来源:origin: fcrepo3/fcrepo
@Test
public void testZip() throws Exception {
Zip.zip(ZIP_FILE, SRC_DIR.listFiles());
ZipFile zf = new ZipFile(ZIP_FILE);
try {
assertEquals(5, zf.size());
} finally {
zf.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!