@Test public void execute() throws Exception { DecompressTasklet tasklet = new DecompressTasklet(); tasklet.setInputResource(new ClassPathResource("/input/products.zip")); File outputDir = new File("./target/decompresstasklet"); if(outputDir.exists()) { FileUtils.deleteDirectory(outputDir); } tasklet.setTargetDirectory(outputDir.getAbsolutePath()); tasklet.setTargetFile("products.txt"); tasklet.execute(null, null); File output = new File(outputDir,"products.txt"); Assert.assertTrue(output.exists()); Assert.assertArrayEquals(EXPECTED_CONTENT, FileUtils.readLines(output).toArray()); }
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputResource.getInputStream())); File targetDirectoryAsFile = new File(targetDirectory); if(!targetDirectoryAsFile.exists()) { FileUtils.forceMkdir(targetDirectoryAsFile); } File target = new File(targetDirectory,targetFile); BufferedOutputStream dest = null; while(zis.getNextEntry() != null) { if(!target.exists()) { target.createNewFile(); } FileOutputStream fos = new FileOutputStream(target); dest = new BufferedOutputStream(fos); IOUtils.copy(zis,dest); dest.flush(); dest.close(); } zis.close(); if(!target.exists()) { throw new IllegalStateException("Could not decompress anything from the archive!"); } return RepeatStatus.FINISHED; }
DecompressTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputResource.getInputStream())); File targetDirectoryAsFile = new File(targetDirectory); if(!targetDirectoryAsFile.exists()) { FileUtils.forceMkdir(targetDirectoryAsFile); } File target = new File(targetDirectory,targetFile); BufferedOutputStream dest = null; while(zis.getNextEntry() != null) { if(!target.exists()) { target.createNewFile(); } FileOutputStream fos = new FileOutputStream(target); dest = new BufferedOutputStream(fos); IOUtils.copy(zis,dest); dest.flush(); dest.close(); } zis.close(); if(!target.exists()) { throw new IllegalStateException("Could not decompress anything from the archive!"); } return RepeatStatus.FINISHED; } }
DecompressTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputResource.getInputStream())); File targetDirectoryAsFile = new File(targetDirectory); if(!targetDirectoryAsFile.exists()) { FileUtils.forceMkdir(targetDirectoryAsFile); } File target = new File(targetDirectory,targetFile); BufferedOutputStream dest = null; while(zis.getNextEntry() != null) { if(!target.exists()) { target.createNewFile(); } FileOutputStream fos = new FileOutputStream(target); dest = new BufferedOutputStream(fos); IOUtils.copy(zis,dest); dest.flush(); dest.close(); } zis.close(); if(!target.exists()) { throw new IllegalStateException("Could not decompress anything from the archive!"); } return RepeatStatus.FINISHED; }  }
DecompressTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputResource.getInputStream())); File targetDirectoryAsFile = new File(targetDirectory); if(!targetDirectoryAsFile.exists()) { FileUtils.forceMkdir(targetDirectoryAsFile); } File target = new File(targetDirectory,targetFile); BufferedOutputStream dest = null; while(zis.getNextEntry() != null) { if(!target.exists()) { target.createNewFile(); } FileOutputStream fos = new FileOutputStream(target); dest = new BufferedOutputStream(fos); IOUtils.copy(zis,dest); dest.flush(); dest.close(); } zis.close(); if(!target.exists()) { throw new IllegalStateException("Could not decompress anything from the archive!"); } return RepeatStatus.FINISHED; }  RepeatStatus execute(StepContribution contribution,
			ChunkContext chunkContext); void setInputResource(Resource inputResource); void setTargetDirectory(String targetDirectory); void setTargetFile(String targetFile); }
DecompressTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputResource.getInputStream())); File targetDirectoryAsFile = new File(targetDirectory); if(!targetDirectoryAsFile.exists()) { FileUtils.forceMkdir(targetDirectoryAsFile); } File target = new File(targetDirectory,targetFile); BufferedOutputStream dest = null; while(zis.getNextEntry() != null) { if(!target.exists()) { target.createNewFile(); } FileOutputStream fos = new FileOutputStream(target); dest = new BufferedOutputStream(fos); IOUtils.copy(zis,dest); dest.flush(); dest.close(); } zis.close(); if(!target.exists()) { throw new IllegalStateException("Could not decompress anything from the archive!"); } return RepeatStatus.FINISHED; }  RepeatStatus execute(StepContribution contribution,
			ChunkContext chunkContext); void setInputResource(Resource inputResource); void setTargetDirectory(String targetDirectory); void setTargetFile(String targetFile);  }