Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在apache beam java sdk中解压缩.tar.gz文件_Java_Compression_Apache Beam_Apache Commons_Minio - Fatal编程技术网

如何在apache beam java sdk中解压缩.tar.gz文件

如何在apache beam java sdk中解压缩.tar.gz文件,java,compression,apache-beam,apache-commons,minio,Java,Compression,Apache Beam,Apache Commons,Minio,在我的apache beam管道中,我得到一个格式为.tar.gz的文件,我想解压缩tar文件并将其内容保存到minio cloud。我使用以下方法解压文件,但尽管如此,我可以将其存储在本地存储上,但它不适用于将其存储到minio cloud,即play.min.io,我使用apache common compress来解压 @DoFn.ProcessElement public void processElement(@Element ReadableFil

在我的apache beam管道中,我得到一个格式为.tar.gz的文件,我想解压缩tar文件并将其内容保存到minio cloud。我使用以下方法解压文件,但尽管如此,我可以将其存储在本地存储上,但它不适用于将其存储到minio cloud,即play.min.io,我使用apache common compress来解压

         @DoFn.ProcessElement
         public void processElement(@Element ReadableFile element, Void) throws IOException {
             InputStream is = Channels.newInputStream(element.open());
             TarArchiveInputStream tis = new TarArchiveInputStream(is);
             File destFile = new File("C:\\Users\\Downloads\\Compressed\\unzip");
                if(!destFile.exists()){
                     destFile.mkdir();
                }
                TarArchiveEntry tarEntry = null;
                while ((tarEntry = tis.getNextTarEntry()) != null) {
                    File outputFile = new File(destFile + File.separator + tarEntry.getName());

                    if(tarEntry.isDirectory()){

                        if(!outputFile.exists()){
                            outputFile.mkdirs();
                        }
                    }else{
                        outputFile.getParentFile().mkdirs();
                        FileOutputStream fos = new FileOutputStream(outputFile); 
                        IOUtils.copy(tis, fos);
                        fos.close();
                    }   
                }
                tis.close();
     }
     } 
管道

PipelineOptions options = PipelineOptionsFactory.create();
        Pipeline pipeline=Pipeline.create(options);
PCollection files=pipeline.apply(FileIO.match().filepattern("C:\\Users\\Downloads\\Compressed\\Ziped.tar.gz"))
                .apply(FileIO.readMatches().withCompression(Compression.GZIP));
        files.apply(ParDo.of(new unzip()));
        pipeline.run().waitUntilFinish();

当在minio上存储文件时,它使用对象存储,但此代码生成一个输出流。有人能帮我写代码吗。 提前谢谢