Jul 13

Java doesn’t provide standard support for using tar archives so a 3rd party implementation is required. One such implementation is provided by ICE Engineering and can be found here.

Here is a simple example of its usage to tar the files in a directory.

		File tarFile = new File("my.tar");
		FileOutputStream out = new FileOutputStream(tarFile);
		TarArchive tar = new TarArchive(out);
		File[] files = directory.listFiles();
		for (File file : files) {
			System.out.println("Adding "+file);
			TarEntry tarEntry = new TarEntry(file);
			tar.writeEntry(tarEntry, false);

written by objects \\ tags: , , , ,