@@ -137,14 +137,19 @@ public static DataSize of(long amount, DataUnit unit) {
137
137
}
138
138
139
139
/**
140
- * Obtain a {@link DataSize} from a text string such as {@code 12MB } using
140
+ * Obtain a {@link DataSize} from a text string such as {@code "5MB" } using
141
141
* {@link DataUnit#BYTES} if no unit is specified.
142
- * <p>Examples:
143
- * <pre>
144
- * "12KB" -- parses as "12 kilobytes"
145
- * "5MB" -- parses as "5 megabytes"
146
- * "20" -- parses as "20 bytes"
147
- * </pre>
142
+ * <h4>Examples</h4>
143
+ * <table border="1">
144
+ * <tr><th>Text</th><th>Parsed As</th><th>Size in Bytes</th></tr>
145
+ * <tr><td>"20"</td><td>20 bytes</td><td>20</td></tr>
146
+ * <tr><td>"20B"</td><td>20 bytes</td><td>20</td></tr>
147
+ * <tr><td>"12KB"</td><td>12 kilobytes</td><td>12,288</td></tr>
148
+ * <tr><td>"5MB"</td><td>5 megabytes</td><td>5,242,880</td></tr>
149
+ * </table>
150
+ * <p>Note that the terms and units used in the above examples are based on
151
+ * <a href="https://en.wikipedia.org/wiki/Binary_prefix">binary prefixes</a>.
152
+ * Consult the {@linkplain DataSize class-level Javadoc} for details.
148
153
* @param text the text to parse
149
154
* @return the parsed {@code DataSize}
150
155
* @see #parse(CharSequence, DataUnit)
@@ -154,19 +159,24 @@ public static DataSize parse(CharSequence text) {
154
159
}
155
160
156
161
/**
157
- * Obtain a {@link DataSize} from a text string such as {@code 12MB } using
162
+ * Obtain a {@link DataSize} from a text string such as {@code "5MB" } using
158
163
* the specified default {@link DataUnit} if no unit is specified.
159
164
* <p>The string starts with a number followed optionally by a unit matching
160
165
* one of the supported {@linkplain DataUnit suffixes}.
161
166
* <p>If neither a unit nor a default {@code DataUnit} is specified,
162
167
* {@link DataUnit#BYTES} will be inferred.
163
- * <p>Examples:
164
- * <pre>
165
- * "12KB" -- parses as "12 kilobytes"
166
- * "5MB" -- parses as "5 megabytes"
167
- * "20" -- parses as "20 kilobytes" (where the {@code defaultUnit} is {@link DataUnit#KILOBYTES})
168
- * "20" -- parses as "20 bytes" (if the {@code defaultUnit} is {@code null})
169
- * </pre>
168
+ * <h4>Examples</h4>
169
+ * <table border="1">
170
+ * <tr><th>Text</th><th>Default Unit</th><th>Parsed As</th><th>Size in Bytes</th></tr>
171
+ * <tr><td>"20"</td><td>{@code null}</td><td>20 bytes</td><td>20</td></tr>
172
+ * <tr><td>"20"</td><td>{@link DataUnit#KILOBYTES KILOBYTES}</td><td>20 kilobytes</td><td>20,480</td></tr>
173
+ * <tr><td>"20B"</td><td>N/A</td><td>20 bytes</td><td>20</td></tr>
174
+ * <tr><td>"12KB"</td><td>N/A</td><td>12 kilobytes</td><td>12,288</td></tr>
175
+ * <tr><td>"5MB"</td><td>N/A</td><td>5 megabytes</td><td>5,242,880</td></tr>
176
+ * </table>
177
+ * <p>Note that the terms and units used in the above examples are based on
178
+ * <a href="https://en.wikipedia.org/wiki/Binary_prefix">binary prefixes</a>.
179
+ * Consult the {@linkplain DataSize class-level Javadoc} for details.
170
180
* @param text the text to parse
171
181
* @param defaultUnit the default {@code DataUnit} to use
172
182
* @return the parsed {@code DataSize}
0 commit comments