You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var printer =FileTreePrettyPrinter.createDefault();
62
-
var tree = printer.prettyPrint("src/example/resources/base");
63
-
System.out.println(tree);
70
+
var printer =FileTreePrettyPrinter.createDefault();// Create a printer with default options
71
+
var tree = printer.prettyPrint("src/example/resources/base");// Pretty print the target folder
72
+
System.out.println(tree);// Admire the result!
64
73
```
65
74
66
75
Result:
67
-
```
76
+
77
+
```text
68
78
base/
69
79
├─ businessPlan.pdf
70
80
├─ businessProject.pdf
@@ -84,7 +94,7 @@ base/
84
94
> [!NOTE]
85
95
> In case of error while reading directories or files, an [UncheckedIOException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/UncheckedIOException.html) is thrown.
86
96
87
-
# Options
97
+
# Customization options
88
98
89
99
*[Filtering](#filtering)
90
100
*[Sorting](#sorting)
@@ -98,8 +108,8 @@ base/
98
108
## Filtering
99
109
Files and directories can be selectively included or excluded using a custom `PathMatcher`.
100
110
101
-
Filtering is independant for files & directories. Files are filtered only if their parent directory pass the directory filter.
102
-
If none of some directory's children match, the directory is still displayed.
111
+
Filtering applies independently to files and directories. Files are filtered only if their parent directory passes the directory filter.
112
+
If none of a directory’s children match, the directory is still displayed.
103
113
104
114
The `PathMatchers` class provides several ready-to-use methods for creating and combining common matchers.
105
115
@@ -116,7 +126,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
116
126
)
117
127
.build();
118
128
```
119
-
```
129
+
130
+
```text
120
131
filtering/
121
132
├─ dir_with_java_files/
122
133
│ ├─ file_B.java
@@ -140,7 +151,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
If your terminal supports them, you can choose to use emojis.
159
-
Folders will have the "📂" emoji, and files will have an emoji depending on their extension (when applicable).
171
+
Folders use the 📂 emoji, and files will have an emoji depending on their extension (when applicable).
160
172
161
173
```java
162
174
// Example: Emojis.java
@@ -165,8 +177,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
165
177
.build();
166
178
```
167
179
168
-
```
169
-
// Run Emojis.java example for exhaustive list
180
+
```text
181
+
// Run Emojis.java example for the full list of emoji mappings
170
182
📂 emojis/
171
183
├─ 📦 file.zip
172
184
├─ 🐳 Dockerfile
@@ -186,7 +198,7 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
186
198
> *Idea for a future version: option to allow custom emoji mapping*
187
199
188
200
## Child limit
189
-
You can set a fixed limit to the number of children displayed for each directory. Each directory and file that pass filter (if set) counts for one.
201
+
You can set a fixed limit to the number of children displayed for each directory. Each directory and file that pass the filter (if set) counts for one.
190
202
191
203
```java
192
204
// Example: ChildLimitStatic.java
@@ -195,7 +207,7 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
195
207
.build();
196
208
```
197
209
198
-
```
210
+
```text
199
211
child_limit_static/
200
212
├─ file_0_1
201
213
├─ folder_1/
@@ -213,7 +225,7 @@ child_limit_static/
213
225
```
214
226
215
227
Or you can also set a limitation function, to dynamically choose the number of children displayed in each directory.
216
-
It avoids cluttering the whole console with known large folders (e.g. `node_modules`) but continue to prettyprint normally other folders.
228
+
This avoids cluttering the result with known large folders (e.g. `node_modules`) while continuing to pretty-print other folders normally.
217
229
218
230
Use the `ChildLimits` class to help you build the limit function that fits your needs.
219
231
@@ -227,7 +239,8 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
Copy file name to clipboardExpand all lines: pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
10
10
<packaging>jar</packaging>
11
11
<name>JFileTreePrettyPrinter</name>
12
-
<description>A lightweight Java library for printing directory structures in a clean, tree-like format.</description>
12
+
<description>A lightweight and flexible Java library to pretty-print directory structures — ideal for documentation, project overviews, or CLI tools.</description>
0 commit comments