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