Created
August 1, 2025 11:58
-
-
Save henryw374/d7396be071f8c507f1ce3dc4549a6105 to your computer and use it in GitHub Desktop.
clojure append to zip file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns create-zip-archive | |
(:import (java.net URI) | |
(java.nio.charset StandardCharsets) | |
(java.nio.file FileSystem FileSystems Files Paths StandardOpenOption))) | |
(let [path (Paths/get "test.zip" (make-array String 0)) | |
uri (URI/create (str "jar:" (.toUri path)))] | |
(with-open [fs (FileSystems/newFileSystem uri {"create" "true"})] | |
(let [nf (FileSystem/.getPath fs "new.txt" (make-array String 0))] | |
(with-open [writer (Files/newBufferedWriter nf, StandardCharsets/UTF_8, (into-array [StandardOpenOption/CREATE]))] | |
(.write writer "hello"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment