私が必要とするのは、一時フォルダを作成し、自分のコンピュータに既に存在するzipフォルダの中に入れることです。内部にzipフォルダを持つ一時フォルダを作成する方法
このコードを作成するための解決策や例は見つかりませんでした。
home/myName/folderTest
(Ubuntu内)にフォルダを作成しました。このfolderTest
の中に、私は一時的なフォルダを作成します。今私は私のジッパーを取得し、このフォルダの中に入れておく必要があります。私はこれを行う方法と私がそれを必要としないときに一時フォルダを削除する方法を知らない。
public static void main(String[] args) throws IOException {
Path rootDirectory = FileSystems.getDefault().getPath("/home/myName/folderTest");
Path tempDirectory = Files.createTempDirectory(rootDirectory, "");
String dirPath = tempDirectory.toString();
System.out.println(dirPath);
try
{
ZipFile zipFile = new ZipFile("/home/myName/zipTest.zip");
ZipParameters parameters = new ZipParameters();
zipFile.addFolder(dirPath, parameters);
}
catch (ZipException e) {
e.printStackTrace();
}
}
このコードはエラーは発生しませんが、zipは一時フォルダにコピーされません。
あなたはすでに試してみましたか? https://stackoverflow.com/questions/617414/how-to-create-a-temporary-directory-folder-in-javaおよびhttps://stackoverflow.com/questions/106770/standard-concise-way-to- – Caramiriel
検索にどのような努力を払うかわからない – ayush
一時フォルダを作成する方法 - https://stackoverflow.com/questions/617414/how-to-create-a-temporary-ディレクトリフォルダー内のJava – ayush