org.fcrepo.utilities.Zip类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中org.fcrepo.utilities.Zip类的一些代码示例,展示了Zip类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zip类的具体详情如下:
包路径:org.fcrepo.utilities.Zip
类名称: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();
  }
}

相关文章

微信公众号

最新文章

更多