List of usage examples for org.apache.commons.compress.tar TarOutputStream write
public void write(final byte[] buffer) throws IOException
From source file:ja.lingo.engine.Exporter.java
private void putCssFile(TarOutputStream tos) throws IOException { byte[] cssRawBytes = getStandaloneCssRaw().getBytes(EXPORT_ENCODING); TarEntry entry = new TarEntry("style.css"); entry.setSize(cssRawBytes.length);/*from ww w . j a v a 2s. c o m*/ tos.putNextEntry(entry); tos.write(cssRawBytes); tos.closeEntry(); }
From source file:ja.lingo.engine.Exporter.java
private void putIndexFile(IArticleList articleList, TarOutputStream tos) throws IOException { byte[] indexFileBytes = getIndexFileContent(articleList).getBytes(EXPORT_ENCODING); TarEntry entry = new TarEntry("index.html"); entry.setSize(indexFileBytes.length); tos.putNextEntry(entry);//from ww w . j a v a 2 s . c om tos.write(indexFileBytes); tos.closeEntry(); }
From source file:ja.lingo.engine.Exporter.java
private void writeArticles(IArticleList articleList, TarOutputStream tos, OutputStream listOs, DecimalFormat format, IMonitor monitor) throws IOException { // list: prefix listOs.write(getListFileHeader().getBytes(EXPORT_ENCODING)); monitor.start(0, articleList.size()); // traverse through articles for (int i = 0; i < articleList.size(); i++) { IArticle article = articleList.get(i); String articleFileName = format.format(i) + ".html"; byte[] bytes = toHtmlStandalone(article, false).getBytes(EXPORT_ENCODING); TarEntry entry = new TarEntry(articleFileName); entry.setSize(bytes.length);/*from w w w . ja v a 2 s. c o m*/ tos.putNextEntry(entry); tos.write(bytes); tos.closeEntry(); // list: entry listOs.write( getListFileEntry(articleFileName, articleList.get(i).getTitle()).getBytes(EXPORT_ENCODING)); monitor.update(i); } // list: suffix listOs.write(getListFileFooter().getBytes(EXPORT_ENCODING)); }
From source file:org.dcm4chex.archive.hsm.FileCopyService.java
private void writeMD5SUM(TarOutputStream tar, List<FileInfo> fileInfos, String[] tarEntryNames) throws IOException { byte[] md5sum = new byte[fileInfos.size() * MD5SUM_ENTRY_LEN]; final TarEntry tarEntry = new TarEntry("MD5SUM"); tarEntry.setSize(md5sum.length);/*w ww.j a v a 2 s . co m*/ tar.putNextEntry(tarEntry); int i = 0; for (int j = 0; j < tarEntryNames.length; j++) { MD5Utils.toHexChars(MD5.toBytes(fileInfos.get(j).md5), md5sum, i); md5sum[i + 32] = ' '; md5sum[i + 33] = ' '; System.arraycopy(tarEntryNames[j].getBytes("US-ASCII"), 0, md5sum, i + 34, 17); md5sum[i + 51] = '\n'; i += MD5SUM_ENTRY_LEN; } tar.write(md5sum); tar.closeEntry(); }
From source file:org.dcm4chex.archive.hsm.FileMoveService.java
private void writeMD5SUM(TarOutputStream tar, FileDTO[] dto, String[] tarEntryNames) throws IOException { byte[] md5sum = new byte[dto.length * MD5SUM_ENTRY_LEN]; final TarEntry tarEntry = new TarEntry("MD5SUM"); tarEntry.setSize(md5sum.length);//w w w.j a v a 2s . c o m tar.putNextEntry(tarEntry); int i = 0; for (int j = 0; j < tarEntryNames.length; j++) { MD5Utils.toHexChars(dto[j].getFileMd5(), md5sum, i); md5sum[i + 32] = ' '; md5sum[i + 33] = ' '; System.arraycopy(tarEntryNames[j].getBytes("US-ASCII"), 0, md5sum, i + 34, 17); md5sum[i + 51] = '\n'; i += MD5SUM_ENTRY_LEN; } tar.write(md5sum); tar.closeEntry(); }