Answers for "stream zip file"

0

stream zip file

try (final OutputStream bufferedOut = new BufferedOutputStream(rawOut);
                            final ZipOutputStream out = new ZipOutputStream(bufferedOut)) {
                            out.setLevel(compressionLevel);
                            for (final FlowFile flowFile : contents) {
                                final String path = keepPath ? getPath(flowFile) : "";
                                final String entryName = path + flowFile.getAttribute(CoreAttributes.FILENAME.key());
                                final ZipEntry zipEntry = new ZipEntry(entryName);
                                zipEntry.setSize(flowFile.getSize());
                                try {
                                    out.putNextEntry(zipEntry);

                                    bin.getSession().exportTo(flowFile, out);
                                    out.closeEntry();
                                    unmerged.remove(flowFile);
                                } catch (ZipException e) {
                                    getLogger().error("Encountered exception merging {}", new Object[] {flowFile}, e);
                                }
                            }

                            out.finish();
                            out.flush();
                        }
Posted by: Guest on December-03-2020

Browse Popular Code Answers by Language