Package org.apache.commons.compress.archivers

Examples of org.apache.commons.compress.archivers.ArchiveStreamFactory


    String archive = (String) workItem.getParameter("Archive");
    List<File> files = (List<File>) workItem.getParameter("Files");
   
    try {
          OutputStream outputStream = new FileOutputStream( new File( archive) );         
          ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("tar", outputStream);
         
      if (files != null) {
        for (File file: files) {
              final TarArchiveEntry entry = new TarArchiveEntry("testdata/test1.xml");
              entry.setModTime(0);
View Full Code Here


  // 文件压缩
  public static File zip(List<String> fileNames, String zipPath, String encoding) {
    try {
      FileOutputStream f = new FileOutputStream(zipPath);
      ZipArchiveOutputStream zos = (ZipArchiveOutputStream) new ArchiveStreamFactory()
          .createArchiveOutputStream(ArchiveStreamFactory.ZIP, f);
      if (null != encoding) {
        zos.setEncoding(encoding);
      }
      for (int i = 0; i < fileNames.size(); i++) {
View Full Code Here

            for(int i=0; i < ba_1k.length; i++){
                ba_1k[i]='a';
            }
            try {
                TarArchiveOutputStream outTarStream =
                    (TarArchiveOutputStream)new ArchiveStreamFactory()
                    .createArchiveOutputStream(ArchiveStreamFactory.TAR, outTarFileStream);
                // Create archive contents
                TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(name + ".txt");
                tarArchiveEntry.setSize(fileSize);
View Full Code Here

        OutputStream out_zip = null;
        ArchiveOutputStream os = null;
        try {
            try {
                out_zip = new FileOutputStream(to);
                os = new ArchiveStreamFactory().createArchiveOutputStream("zip", out_zip);
                os.putArchiveEntry(new ZipArchiveEntry(from.getName()));
                IOUtils.copy(new FileInputStream(from), os);
                os.closeArchiveEntry();
            } finally {
                if (os != null) {
View Full Code Here

                if ("tar.gz".equals(artefact.getType())) {
                    InputStream inputStream = content.getContent();
                    ais = new TarArchiveInputStream(new GZIPInputStream(inputStream));
                } else {
                    InputStream inputStream = content.getContent();
                    ais = new ArchiveStreamFactory().createArchiveInputStream(artefact.getType(), inputStream);
                }
                ArchiveEntry entry = null;
                boolean needContainerHome = homeDir == null;
                while ((entry = ais.getNextEntry()) != null) {
                    File targetFile;
View Full Code Here

            file = zipFile;
        }

        ArchiveInputStream in = null;
        try {
            in = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(new FileInputStream(file)));
            final byte[] buff = new byte[1024];
            ArchiveEntry entry;
            while ((entry = in.getNextEntry()) != null) {
                final File extractTarget = new File(targetDir.getAbsolutePath(), entry.getName());
                if (entry.isDirectory()) {
View Full Code Here

        }
    }

    private static MediaType detectArchiveFormat(byte[] prefix, int length) {
        try {
            ArchiveStreamFactory factory = new ArchiveStreamFactory();
            ArchiveInputStream ais = factory.createArchiveInputStream(
                    new ByteArrayInputStream(prefix, 0, length));
            try {
                if ((ais instanceof TarArchiveInputStream)
                        && !TarArchiveInputStream.matches(prefix, length)) {
                    // ArchiveStreamFactory is too relaxed, see COMPRESS-117
View Full Code Here

                            Long.toString( System.currentTimeMillis() ) );
            properties.put( Tomcat7Runner.ENABLE_NAMING_KEY, Boolean.toString( enableNaming ) );
            properties.put( Tomcat7Runner.ACCESS_LOG_VALVE_FORMAT_KEY, accessLogValveFormat );
            properties.put( Tomcat7Runner.HTTP_PROTOCOL_KEY, connectorHttpProtocol );

            os = new ArchiveStreamFactory().createArchiveOutputStream( ArchiveStreamFactory.JAR,
                                                                       execWarJarOutputStream );

            if ( "war".equals( project.getPackaging() ) )
            {
View Full Code Here

        tmpWar.deleteOnExit();

        try
        {
            warOutputStream = new FileOutputStream( tmpWar );
            os = new ArchiveStreamFactory().createArchiveOutputStream( ArchiveStreamFactory.JAR, warOutputStream );
            os.putArchiveEntry( new JarArchiveEntry( "META-INF/context.xml" ) );
            IOUtils.copy( new FileInputStream( contextXmlFile ), os );
            os.closeArchiveEntry();

            JarFile jarFile = new JarFile( warFile );
View Full Code Here

            properties.put( Tomcat7Runner.ENABLE_NAMING_KEY, Boolean.toString( enableNaming ) );
            properties.put( Tomcat7Runner.ACCESS_LOG_VALVE_FORMAT_KEY, accessLogValveFormat );
            properties.put( Tomcat7Runner.HTTP_PROTOCOL_KEY, connectorHttpProtocol );
            properties.put( Tomcat7Runner.CODE_SOURCE_CONTEXT_PATH, path );

            os = new ArchiveStreamFactory().createArchiveOutputStream( ArchiveStreamFactory.JAR,
                                                                       execWarJarOutputStream );

            extractJarToArchive( new JarFile( projectArtifact.getFile() ), os );

            if ( serverXml != null && serverXml.exists() )
View Full Code Here

TOP

Related Classes of org.apache.commons.compress.archivers.ArchiveStreamFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.