当前位置: 首页>>代码示例>>Java>>正文


Java TarArchiveEntry.getName方法代码示例

本文整理汇总了Java中org.apache.commons.compress.archivers.tar.TarArchiveEntry.getName方法的典型用法代码示例。如果您正苦于以下问题:Java TarArchiveEntry.getName方法的具体用法?Java TarArchiveEntry.getName怎么用?Java TarArchiveEntry.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.compress.archivers.tar.TarArchiveEntry的用法示例。


在下文中一共展示了TarArchiveEntry.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractTar

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private static void extractTar(String dataIn, String dataOut) throws IOException {

        try (TarArchiveInputStream inStream = new TarArchiveInputStream(
                new GzipCompressorInputStream(new BufferedInputStream(new FileInputStream(dataIn))))) {
            TarArchiveEntry tarFile;
            while ((tarFile = (TarArchiveEntry) inStream.getNextEntry()) != null) {
                if (tarFile.isDirectory()) {
                    new File(dataOut + tarFile.getName()).mkdirs();
                } else {
                    int count;
                    byte data[] = new byte[BUFFER_SIZE];

                    FileOutputStream fileInStream = new FileOutputStream(dataOut + tarFile.getName());
                    BufferedOutputStream outStream=  new BufferedOutputStream(fileInStream, BUFFER_SIZE);
                    while ((count = inStream.read(data, 0, BUFFER_SIZE)) != -1) {
                        outStream.write(data, 0, count);
                    }
                }
            }
        }
    }
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:22,代码来源:DL4JSentimentAnalysisExample.java

示例2: addFile

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * @deprecated see {@link PLP5ProjectParser#parse(File)}
 */
private static void addFile(TarArchiveInputStream plpInputStream,
		TarArchiveEntry entry, File assembleFile, List<ASMFile> projectFiles)
		throws IOException
{
	byte[] content = new byte[(int) entry.getSize()];
	int currentIndex = 0;
	while (currentIndex < entry.getSize())
	{
		plpInputStream.read(content, currentIndex, content.length - currentIndex);
		currentIndex++;
	}
	if (entry.getName().endsWith(".asm"))
	{
		ASMFile asmFile = new SimpleASMFile(null, entry.getName());
		asmFile.setContent(new String(content));
		projectFiles.add(asmFile);
	}
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:22,代码来源:FileUtil.java

示例3: addFile

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addFile(TarArchiveEntry entry) throws IOException
{
	byte[] content = new byte[(int) entry.getSize()];
	int currentIndex = 0;
	while (currentIndex < entry.getSize())
	{
		inputStream.read(content, currentIndex, content.length - currentIndex);
		currentIndex++;
	}
	if (entry.getName().endsWith(".asm"))
	{
		ASMFile asmFile = new SimpleASMFile(project, entry.getName());
		asmFile.setContent(new String(content));
		
		project.add(asmFile);
	}
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:18,代码来源:PLP5ProjectParser.java

示例4: dearchive

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * 文件 解归档
 *
 * @param destFile
 *            目标文件
 * @param tais
 *            ZipInputStream
 * @throws Exception
 */
private static void dearchive(File destFile, TarArchiveInputStream tais)
        throws Exception {

    TarArchiveEntry entry = null;
    while ((entry = tais.getNextTarEntry()) != null) {

        // 文件
        String dir = destFile.getPath() + File.separator + entry.getName();

        File dirFile = new File(dir);

        // 文件检查
        fileProber(dirFile);

        if (entry.isDirectory()) {
            dirFile.mkdirs();
        } else {
            dearchiveFile(dirFile, tais);
        }

    }
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:32,代码来源:TarUtils.java

示例5: run

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@Override
public void run(Parameters p, PrintStream output) throws Exception {
  TarArchiveInputStream tais = new TarArchiveInputStream(StreamCreator.openInputStream(p.getString("input")));
  ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(p.getString("output")));
  boolean quiet = p.get("quiet", false);

  while(true) {
    TarArchiveEntry tarEntry = tais.getNextTarEntry();
    if(tarEntry == null) break;
    if(!tarEntry.isFile()) continue;
    if(!tais.canReadEntryData(tarEntry)) continue;

    if(!quiet) System.err.println("# "+tarEntry.getName());

    ZipEntry forData = new ZipEntry(tarEntry.getName());
    forData.setSize(tarEntry.getSize());
    zos.putNextEntry(forData);
    StreamUtil.copyStream(tais, zos);
    zos.closeEntry();
  }
  tais.close();
  zos.close();
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:24,代码来源:TarToZipConverter.java

示例6: unTgz

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private static List<String> unTgz(File tarFile, File directory) throws IOException {
  List<String> result = new ArrayList<>();
  try (TarArchiveInputStream in = new TarArchiveInputStream(
          new GzipCompressorInputStream(new FileInputStream(tarFile)))) {
    TarArchiveEntry entry = in.getNextTarEntry();
    while (entry != null) {
      if (entry.isDirectory()) {
        entry = in.getNextTarEntry();
        continue;
      }
      File curfile = new File(directory, entry.getName());
      File parent = curfile.getParentFile();
      if (!parent.exists()) {
        parent.mkdirs();
      }
      try (OutputStream out = new FileOutputStream(curfile)) {
        IOUtils.copy(in, out);
      }
      result.add(entry.getName());
      entry = in.getNextTarEntry();
    }
  }
  return result;
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:25,代码来源:HeliumBundleFactory.java

示例7: untarFile

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
public static void untarFile(File file) throws IOException {
    FileInputStream fileInputStream = null;
    String currentDir = file.getParent();
    try {
        fileInputStream = new FileInputStream(file);
        GZIPInputStream gzipInputStream = new GZIPInputStream(fileInputStream);
        TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(gzipInputStream);

        TarArchiveEntry tarArchiveEntry;

        while (null != (tarArchiveEntry = tarArchiveInputStream.getNextTarEntry())) {
            if (tarArchiveEntry.isDirectory()) {
                FileUtils.forceMkdir(new File(currentDir + File.separator + tarArchiveEntry.getName()));
            } else {
                byte[] content = new byte[(int) tarArchiveEntry.getSize()];
                int offset = 0;
                tarArchiveInputStream.read(content, offset, content.length - offset);
                FileOutputStream outputFile = new FileOutputStream(currentDir + File.separator + tarArchiveEntry.getName());
                org.apache.commons.io.IOUtils.write(content, outputFile);
                outputFile.close();
            }
        }
    } catch (FileNotFoundException e) {
        throw new IOException(e.getStackTrace().toString());
    }
}
 
开发者ID:foundation-runtime,项目名称:jenkins-openstack-deployment-plugin,代码行数:27,代码来源:CompressUtils.java

示例8: unarchive

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@Override
public void unarchive(InputStream source, File target) {
    try (TarArchiveInputStream tIn = new TarArchiveInputStream(source)) {

        TarArchiveEntry entry = tIn.getNextTarEntry();
        while (entry != null) {
            if (entry.isDirectory()) {
                entry = tIn.getNextTarEntry();
                continue;
            }
            File curfile = new File(target, entry.getName());
            File parent = curfile.getParentFile();
            if (!parent.exists()) {
                parent.mkdirs();
            }
            try (OutputStream out = new FileOutputStream(curfile)) {
                IOUtils.copy(tIn, out);

                entry = tIn.getNextTarEntry();
            }
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:kibertoad,项目名称:swampmachine,代码行数:26,代码来源:TarArchiver.java

示例9: next

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@Override
public InputStreamable next() {
  if(needsConsume) consumeHeader();

  final TarArchiveEntry prev = current;
  needsConsume = true; // need to pull next lazily so that they can read the adjacent stream:
  return new InputStreamable() {
    @Override
    public String getName() {
      return prev.getName();
    }

    @Override
    public InputStream getRawInputStream() throws IOException {
      assert(needsConsume);
      // If they want it, slurp it to memory so that we they can't close the underlying Tar input stream.
      return new ByteArrayInputStream(StreamFns.readBytes(is, IntMath.fromLong(prev.getSize())));
    }
  };
}
 
开发者ID:jjfiv,项目名称:chai,代码行数:21,代码来源:TarInputHandler.java

示例10: unzipTAREntry

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void unzipTAREntry(@NonNull final Context context, TarArchiveInputStream zipFileStream, TarArchiveEntry entry,
                           String outputDir) throws IOException {
    String name = entry.getName();
    if (entry.isDirectory()) {
        FileUtil.mkdir(new File(outputDir, name), context);
        return;
    }
    File outputFile = new File(outputDir, name);
    if (!outputFile.getParentFile().exists()) {
        FileUtil.mkdir(outputFile.getParentFile(), context);
    }

    BufferedOutputStream outputStream = new BufferedOutputStream(
            FileUtil.getOutputStream(outputFile, context, entry.getRealSize()));
    try {
        int len;
        byte buf[] = new byte[GenericCopyUtil.DEFAULT_BUFFER_SIZE];
        while ((len = zipFileStream.read(buf)) > 0) {

            outputStream.write(buf, 0, len);
            ServiceWatcherUtil.POSITION += len;
        }
    } finally {
        outputStream.close();
    }
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:27,代码来源:ExtractService.java

示例11: extractTarBallEntry

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * Private Helper Method to Perform Extract for a Tarball Entry.
 *
 * @param tarArchiveInputStream
 * @param entry
 * @param outputDirectory
 * @throws java.io.IOException
 */
private static void extractTarBallEntry(TarArchiveInputStream tarArchiveInputStream, TarArchiveEntry entry, File outputDirectory)
        throws IOException {
    final File outputFile = new File(outputDirectory, entry.getName());
    if (entry.isDirectory()) {
        if (!outputFile.exists()) {
            if (!outputFile.mkdirs()) {
                throw new IllegalStateException(String.format("Couldn't create directory %s.", outputFile.getAbsolutePath()));
            }
        }
    } else {
        final OutputStream outputFileStream = new FileOutputStream(outputFile);
        IOUtils.copy(tarArchiveInputStream, outputFileStream);
        outputFileStream.close();
    }
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:24,代码来源:ArchiveUtility.java

示例12: extractFileByName

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private File extractFileByName(File archive, String filenameToExtract) throws IOException {
    File baseDir = new File(FileUtils.getTempDirectoryPath());
    File expectedFile = new File(baseDir, filenameToExtract);
    expectedFile.delete();
    assertThat(expectedFile.exists(), is(false));

    TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(new GZIPInputStream(
            new BufferedInputStream(new FileInputStream(archive))));
    TarArchiveEntry entry;
    while ((entry = tarArchiveInputStream.getNextTarEntry()) != null) {
        String individualFiles = entry.getName();
        // there should be only one file in this archive
        assertThat(individualFiles, equalTo("executableFile.sh"));
        IOUtils.copy(tarArchiveInputStream, new FileOutputStream(expectedFile));
        if ((entry.getMode() & 0755) == 0755) {
            expectedFile.setExecutable(true);
        }
    }
    tarArchiveInputStream.close();
    return expectedFile;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:22,代码来源:CompressArchiveUtilTest.java

示例13: untarGzip

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
public static void untarGzip(final InputStream inputStream, final File outputDir){
    try(TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(
            new GZIPInputStream(
                    inputStream))){
        TarArchiveEntry entry;
        while((entry = tarArchiveInputStream.getNextTarEntry()) != null){
            final File outputFile = new File(outputDir, entry.getName());
            if(entry.isFile()){
                final OutputStream outputStream = new FileOutputStream(outputFile);
                IOUtils.copy(tarArchiveInputStream, outputStream);
                outputStream.close();
            }
            else if (entry.isDirectory()){
                if(!outputFile.exists()){
                    outputFile.mkdirs();
                }
            }
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:korwe,项目名称:kordapt,代码行数:24,代码来源:CompressionUtil.java

示例14: extractTar

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void extractTar( String tarFilePath, String outputDirPath ) {

        TarArchiveEntry entry = null;
        try (TarArchiveInputStream tis = new TarArchiveInputStream(new FileInputStream(tarFilePath))) {
            while ( (entry = (TarArchiveEntry) tis.getNextEntry()) != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Extracting " + entry.getName());
                }
                File entryDestination = new File(outputDirPath, entry.getName());
                if (entry.isDirectory()) {
                    entryDestination.mkdirs();
                } else {
                    entryDestination.getParentFile().mkdirs();
                    OutputStream out = new BufferedOutputStream(new FileOutputStream(entryDestination));
                    IoUtils.copyStream(tis, out, false, true);
                }
                if (OperatingSystemType.getCurrentOsType() != OperatingSystemType.WINDOWS) {//check if the OS is UNIX
                    // set file/dir permissions, after it is created
                    Files.setPosixFilePermissions(entryDestination.getCanonicalFile().toPath(),
                                                  getPosixFilePermission(entry.getMode()));
                }
            }
        } catch (Exception e) {
            String errorMsg = null;
            if (entry != null) {
                errorMsg = "Unable to untar " + entry.getName() + " from " + tarFilePath
                           + ".Target directory '" + outputDirPath + "' is in inconsistent state.";
            } else {
                errorMsg = "Could not read data from " + tarFilePath;
            }
            throw new FileSystemOperationException(errorMsg, e);
        }

    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:35,代码来源:LocalFileSystemOperations.java

示例15: extractTarGZip

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void extractTarGZip( String tarGzipFilePath, String outputDirPath ) {

        TarArchiveEntry entry = null;
        try (TarArchiveInputStream tis = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(tarGzipFilePath)))) {
            while ( (entry = (TarArchiveEntry) tis.getNextEntry()) != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Extracting " + entry.getName());
                }
                File entryDestination = new File(outputDirPath, entry.getName());
                if (entry.isDirectory()) {
                    entryDestination.mkdirs();
                } else {
                    entryDestination.getParentFile().mkdirs();
                    OutputStream out = new BufferedOutputStream(new FileOutputStream(entryDestination));
                    IoUtils.copyStream(tis, out, false, true);
                }
                if (OperatingSystemType.getCurrentOsType() != OperatingSystemType.WINDOWS) {//check if the OS is UNIX
                    // set file/dir permissions, after it is created
                    Files.setPosixFilePermissions(entryDestination.getCanonicalFile().toPath(),
                                                  getPosixFilePermission(entry.getMode()));
                }
            }
        } catch (Exception e) {
            String errorMsg = null;
            if (entry != null) {
                errorMsg = "Unable to gunzip " + entry.getName() + " from " + tarGzipFilePath
                           + ".Target directory '" + outputDirPath + "' is in inconsistent state.";
            } else {
                errorMsg = "Could not read data from " + tarGzipFilePath;
            }
            throw new FileSystemOperationException(errorMsg, e);
        }

    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:35,代码来源:LocalFileSystemOperations.java


注:本文中的org.apache.commons.compress.archivers.tar.TarArchiveEntry.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。