Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created April 16, 2025 14:36
Show Gist options
  • Save aspose-com-gists/88bf4be14a680581d7644d341789c065 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/88bf4be14a680581d7644d341789c065 to your computer and use it in GitHub Desktop.
Create CPIO file in Java
// Create CPIO file
import com.aspose.zip.CpioArchive;
public class main {
public static void main(String[] args) {
// Define the path for the working directory.
String dataDir = "/files/data/";
String outDir = "/Desktop/";
// Initialize an object of the CpioArchive class.
try (CpioArchive archive = new CpioArchive()) {
// The createEntries method will add to the archive all the files and directories recursively in the directory given.
archive.createEntries(dataDir);
// Invoke the save method to save archive to the destination file provided.
archive.save(outDir + "archive.cpio");
}
System.out.println("Successfully Compressed Files");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment