List of usage examples for org.apache.commons.compress.tar TarOutputStream close
public void close() throws IOException
From source file:ja.lingo.engine.Exporter.java
public void toFile(String fileName, IArticleList articleList, IMonitor monitor) throws IOException { File listTempFile = EngineFiles.createTempFile("html_export_list.html"); TarOutputStream tos = null; try {/*from ww w.ja v a 2 s . c o m*/ tos = new TarOutputStream( new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(fileName)))); DecimalFormat format = createFormat(articleList.size() - 1); OutputStream listOs = null; try { listOs = new BufferedOutputStream(new FileOutputStream(listTempFile)); writeArticles(articleList, tos, listOs, format, monitor); } finally { if (listOs != null) { try { listOs.close(); } catch (IOException e) { LOG.error("Exception caught when tried to close list HTML FileOutputStream", e); } } } putListFile(listTempFile, tos); putIndexFile(articleList, tos); putCssFile(tos); tos.finish(); monitor.finish(); } finally { if (tos != null) { try { tos.close(); } catch (IOException e) { LOG.error("Exception caught when tried to close TarOutputStream", e); } } listTempFile.delete(); } }
From source file:org.dcm4chex.archive.hsm.FileCopyService.java
private void mkTar(List<FileInfo> fileInfos, File tarFile, String[] tarEntryNames) throws Exception { try {/*from w ww .j a v a 2 s.c o m*/ if (tarFile.getParentFile().mkdirs()) { log.info("M-WRITE " + tarFile.getParent()); } log.info("M-WRITE " + tarFile); TarOutputStream tar = new TarOutputStream(new FileOutputStream(tarFile)); try { writeMD5SUM(tar, fileInfos, tarEntryNames); for (int i = 0; i < tarEntryNames.length; i++) { writeFile(tar, fileInfos.get(i), tarEntryNames[i]); } } finally { tar.close(); } if (verifyCopy) { VerifyTar.verify(tarFile, new byte[bufferSize]); } } catch (Exception e) { log.error("M-DELETE tar file due to an error! " + tarFile); tarFile.delete(); throw e; } }
From source file:org.dcm4chex.archive.hsm.FileMoveService.java
private File[] mkTar(FileDTO[] dto, File tarFile, String[] tarEntryNames) throws Exception { File[] srcFiles = new File[dto.length]; try {//from w w w .j a v a 2 s . com if (tarFile.getParentFile().mkdirs()) { log.info("M-WRITE " + tarFile.getParent()); } log.info("M-WRITE " + tarFile); TarOutputStream tar = new TarOutputStream(new FileOutputStream(tarFile)); try { writeMD5SUM(tar, dto, tarEntryNames); for (int i = 0; i < tarEntryNames.length; i++) { srcFiles[i] = writeFile(tar, dto[i], tarEntryNames[i]); } } finally { tar.close(); } if (verifyCopy) { VerifyTar.verify(tarFile, new byte[bufferSize]); } } catch (Exception e) { deleteFile(tarFile); throw e; } return srcFiles; }