Skip to content

Commit 3579030

Browse files
author
Oliver Weiler
authored
Update README.md
1 parent 689d90b commit 3579030

1 file changed

Lines changed: 8 additions & 36 deletions

File tree

README.md

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,41 +55,7 @@ implementation("io.github.helpermethod:zip-forge:0.1.0")
5555

5656
## Java
5757

58-
Call `ZipForge.createZipFile` to create a ZIP file at the designated location.
59-
60-
```java
61-
import java.nio.charset.StandardCharsets;
62-
63-
import static io.github.helpermethod.zip_forge.ZipForge.createZipFile;
64-
65-
class ZipForgeDemo {
66-
public static void main(String[] args) {
67-
// creates an empty ZIP file
68-
createZipFile(Paths.get("/home/helpermethod/demo.zip"), () -> {});
69-
}
70-
}
71-
```
72-
73-
Use the `ZipForge.file` method to add files to the ZIP file. The file content can be a `String` or a `byte[]`.
74-
75-
```java
76-
import java.nio.charset.StandardCharsets;
77-
78-
import static io.github.helpermethod.zip_forge.ZipForge.createZipFile;
79-
import static io.github.helpermethod.zip_forge.ZipForge.file;
80-
import static io.github.helpermethod.zip_forge.ZipForge.directory;
81-
import static java.nio.charset.StandardCharsets.UTF_8;
82-
83-
class ZipForgeDemo {
84-
public static void main(String[] args) {
85-
createZipFile(Paths.get("/home/helpermethod/demo.zip"), () -> {
86-
file("a.txt", "a");
87-
});
88-
}
89-
}
90-
```
91-
92-
The `ZipForge.directory` method adds directories to the ZIP file and can itself contain `file` or `directory` invocations.
58+
An example is worth a thousand words.
9359

9460
```java
9561
import java.nio.charset.StandardCharsets;
@@ -101,12 +67,18 @@ import static java.nio.charset.StandardCharsets.UTF_8;
10167

10268
class ZipForgeDemo {
10369
public static void main(String[] args) {
70+
// creates a ZIP file named demo.zip in the /home/helpermethod directory
10471
createZipFile(Paths.get("/home/helpermethod/demo.zip"), () -> {
72+
// file content can be specified as a String...
10573
file("a.txt", "a");
10674
directory("d", () -> {
75+
// ... or a byte[]
10776
file("b.txt", "b".getBytes(UTF_8));
10877
file("c.txt", "c");
109-
directory("e", () -> file("f.txt", "f"));
78+
// directories can be nested
79+
directory("e", () -> {
80+
file("f.txt", "f")
81+
});
11082
});
11183
});
11284
}

0 commit comments

Comments
 (0)