org.apache.tools.tar.TarOutputStream Java Examples
The following examples show how to use
org.apache.tools.tar.TarOutputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestFileUtil.java From hadoop with Apache License 2.0 | 5 votes |
@Test (timeout = 30000) public void testUnTar() throws IOException { setupDirs(); // make a simple tar: final File simpleTar = new File(del, FILE); OutputStream os = new FileOutputStream(simpleTar); TarOutputStream tos = new TarOutputStream(os); try { TarEntry te = new TarEntry("/bar/foo"); byte[] data = "some-content".getBytes("UTF-8"); te.setSize(data.length); tos.putNextEntry(te); tos.write(data); tos.closeEntry(); tos.flush(); tos.finish(); } finally { tos.close(); } // successfully untar it into an existing dir: FileUtil.unTar(simpleTar, tmp); // check result: assertTrue(new File(tmp, "/bar/foo").exists()); assertEquals(12, new File(tmp, "/bar/foo").length()); final File regularFile = new File(tmp, "QuickBrownFoxJumpsOverTheLazyDog"); regularFile.createNewFile(); assertTrue(regularFile.exists()); try { FileUtil.unTar(simpleTar, regularFile); assertTrue("An IOException expected.", false); } catch (IOException ioe) { // okay } }
Example #2
Source File: TestFileUtil.java From big-c with Apache License 2.0 | 5 votes |
@Test (timeout = 30000) public void testUnTar() throws IOException { setupDirs(); // make a simple tar: final File simpleTar = new File(del, FILE); OutputStream os = new FileOutputStream(simpleTar); TarOutputStream tos = new TarOutputStream(os); try { TarEntry te = new TarEntry("/bar/foo"); byte[] data = "some-content".getBytes("UTF-8"); te.setSize(data.length); tos.putNextEntry(te); tos.write(data); tos.closeEntry(); tos.flush(); tos.finish(); } finally { tos.close(); } // successfully untar it into an existing dir: FileUtil.unTar(simpleTar, tmp); // check result: assertTrue(new File(tmp, "/bar/foo").exists()); assertEquals(12, new File(tmp, "/bar/foo").length()); final File regularFile = new File(tmp, "QuickBrownFoxJumpsOverTheLazyDog"); regularFile.createNewFile(); assertTrue(regularFile.exists()); try { FileUtil.unTar(simpleTar, regularFile); assertTrue("An IOException expected.", false); } catch (IOException ioe) { // okay } }
Example #3
Source File: TarCopyAction.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public StreamAction(TarOutputStream tarOutStr) { this.tarOutStr = tarOutStr; }
Example #4
Source File: TarCopyAction.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public StreamAction(TarOutputStream tarOutStr) { this.tarOutStr = tarOutStr; }
Example #5
Source File: TarCopyAction.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public StreamAction(TarOutputStream tarOutStr) { this.tarOutStr = tarOutStr; }
Example #6
Source File: TarCopyAction.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public StreamAction(TarOutputStream tarOutStr) { this.tarOutStr = tarOutStr; }
Example #7
Source File: Deb.java From ganttproject with GNU General Public License v3.0 | 4 votes |
private File createDataFile () throws IOException { File dataFile = new File (_tempFolder, "data.tar.gz"); Tar dataTar = new Tar (); dataTar.setProject (getProject ()); dataTar.setTaskName (getTaskName ()); dataTar.setDestFile (dataFile); dataTar.setCompression (GZIP_COMPRESSION_METHOD); dataTar.setLongfile(GNU_LONGFILE_MODE); if ( _data.size () > 0 ) { // add folders for (Iterator dataFoldersIter = _dataFolders.iterator (); dataFoldersIter.hasNext ();) { String targetFolder = (String) dataFoldersIter.next (); TarFileSet targetFolderSet = dataTar.createTarFileSet (); targetFolderSet.setFile (_tempFolder); targetFolderSet.setFullpath (targetFolder); targetFolderSet.setUserName ("root"); targetFolderSet.setGroup ("root"); } // add actual data for (int i = 0; i < _data.size (); i++) { TarFileSet data = (TarFileSet) _data.get (i); if (data.getUserName() == null || data.getUserName().trim().length() == 0) data.setUserName ("root"); if (data.getGroup() == null || data.getGroup().trim().length() == 0) data.setGroup ("root"); dataTar.add (data); } dataTar.execute (); } else { // create an empty data.tar.gz file which is still a valid tar TarOutputStream tarStream = new TarOutputStream( new GZipOutputStream( new BufferedOutputStream(new FileOutputStream(dataFile)), Deflater.BEST_COMPRESSION ) ); tarStream.close(); } return dataFile; }
Example #8
Source File: ProjectManagerStub.java From p3-batchrefine with Apache License 2.0 | 4 votes |
@Override public void exportProject(long projectId, TarOutputStream tos) throws IOException { }