Skip to content

Commit c20dacf

Browse files
committed
Javadoc
1 parent ed8253c commit c20dacf

File tree

13 files changed

+68
-51
lines changed

13 files changed

+68
-51
lines changed

src/main/java/org/apache/commons/io/CopyUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ public static int copy(final InputStream input, final OutputStream output) throw
178178
/**
179179
* Copies and convert bytes from an {@link InputStream} to chars on a
180180
* {@link Writer}.
181-
* The platform's default encoding is used for the byte-to-char conversion.
181+
* <p>
182+
* This method uses the virtual machine's {@link Charset#defaultCharset() default charset} for byte-to-char conversion.
183+
* </p>
182184
*
183185
* @param input the {@link InputStream} to read from
184186
* @param output the {@link Writer} to write to
@@ -218,7 +220,9 @@ public static void copy(
218220
/**
219221
* Serialize chars from a {@link Reader} to bytes on an
220222
* {@link OutputStream}, and flush the {@link OutputStream}.
221-
* Uses the default platform encoding.
223+
* <p>
224+
* This method uses the virtual machine's {@link Charset#defaultCharset() default charset} for byte-to-char conversion.
225+
* </p>
222226
*
223227
* @param input the {@link Reader} to read from
224228
* @param output the {@link OutputStream} to write to
@@ -288,7 +292,9 @@ public static int copy(
288292
* Serialize chars from a {@link String} to bytes on an
289293
* {@link OutputStream}, and
290294
* flush the {@link OutputStream}.
291-
* Uses the platform default encoding.
295+
* <p>
296+
* This method uses the virtual machine's {@link Charset#defaultCharset() default charset} for byte-to-char conversion.
297+
* </p>
292298
*
293299
* @param input the {@link String} to read from
294300
* @param output the {@link OutputStream} to write to

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,14 +2733,14 @@ public static byte[] readFileToByteArray(final File file) throws IOException {
27332733
}
27342734

27352735
/**
2736-
* Reads the contents of a file into a String using the default encoding for the VM.
2737-
* The file is always closed.
2736+
* Reads the contents of a file into a String using the virtual machine's {@link Charset#defaultCharset() default charset}. The
2737+
* file is always closed.
27382738
*
27392739
* @param file the file to read, must not be {@code null}
27402740
* @return the file contents, never {@code null}
27412741
* @throws NullPointerException if file is {@code null}.
2742-
* @throws IOException if an I/O error occurs, including when the file does not exist, is a directory rather than a
2743-
* regular file, or for some other reason why the file cannot be opened for reading.
2742+
* @throws IOException if an I/O error occurs, including when the file does not exist, is a directory rather than a regular file, or for some other
2743+
* reason why the file cannot be opened for reading.
27442744
* @since 1.3.1
27452745
* @deprecated Use {@link #readFileToString(File, Charset)} instead (and specify the appropriate encoding)
27462746
*/
@@ -2782,14 +2782,14 @@ public static String readFileToString(final File file, final String charsetName)
27822782
}
27832783

27842784
/**
2785-
* Reads the contents of a file line by line to a List of Strings using the default encoding for the VM.
2785+
* Reads the contents of a file line by line to a List of Strings using the virtual machine's {@link Charset#defaultCharset() default charset}.
27862786
* The file is always closed.
27872787
*
27882788
* @param file the file to read, must not be {@code null}
27892789
* @return the list of Strings representing each line in the file, never {@code null}
27902790
* @throws NullPointerException if file is {@code null}.
2791-
* @throws IOException if an I/O error occurs, including when the file does not exist, is a directory rather than a
2792-
* regular file, or for some other reason why the file cannot be opened for reading.
2791+
* @throws IOException if an I/O error occurs, including when the file does not exist, is a directory rather than a regular file, or for some other
2792+
* reason why the file cannot be opened for reading.
27932793
* @since 1.3
27942794
* @deprecated Use {@link #readLines(File, Charset)} instead (and specify the appropriate encoding)
27952795
*/
@@ -3201,7 +3201,7 @@ public static boolean waitFor(final File file, final int seconds) {
32013201
}
32023202

32033203
/**
3204-
* Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM.
3204+
* Writes a CharSequence to a file creating the file if it does not exist using the virtual machine's {@link Charset#defaultCharset() default charset}.
32053205
*
32063206
* @param file the file to write
32073207
* @param data the content to write to the file
@@ -3215,12 +3215,11 @@ public static void write(final File file, final CharSequence data) throws IOExce
32153215
}
32163216

32173217
/**
3218-
* Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM.
3218+
* Writes a CharSequence to a file creating the file if it does not exist using the virtual machine's {@link Charset#defaultCharset() default charset}.
32193219
*
32203220
* @param file the file to write
32213221
* @param data the content to write to the file
3222-
* @param append if {@code true}, then the data will be added to the
3223-
* end of the file rather than overwriting
3222+
* @param append if {@code true}, then the data will be added to the end of the file rather than overwriting
32243223
* @throws IOException in case of an I/O error
32253224
* @since 2.1
32263225
* @deprecated Use {@link #write(File, CharSequence, Charset, boolean)} instead (and specify the appropriate encoding)
@@ -3491,7 +3490,7 @@ public static void writeLines(final File file, final String charsetName, final C
34913490
}
34923491

34933492
/**
3494-
* Writes a String to a file creating the file if it does not exist using the default encoding for the VM.
3493+
* Writes a String to a file creating the file if it does not exist using the virtual machine's {@link Charset#defaultCharset() default charset}.
34953494
*
34963495
* @param file the file to write
34973496
* @param data the content to write to the file
@@ -3504,12 +3503,11 @@ public static void writeStringToFile(final File file, final String data) throws
35043503
}
35053504

35063505
/**
3507-
* Writes a String to a file creating the file if it does not exist using the default encoding for the VM.
3506+
* Writes a String to a file creating the file if it does not exist using the virtual machine's {@link Charset#defaultCharset() default charset}.
35083507
*
35093508
* @param file the file to write
35103509
* @param data the content to write to the file
3511-
* @param append if {@code true}, then the String will be added to the
3512-
* end of the file rather than overwriting
3510+
* @param append if {@code true}, then the String will be added to the end of the file rather than overwriting
35133511
* @throws IOException in case of an I/O error
35143512
* @since 2.1
35153513
* @deprecated Use {@link #writeStringToFile(File, String, Charset, boolean)} instead (and specify the appropriate encoding)

src/main/java/org/apache/commons/io/HexDump.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ public static void dump(final byte[] data, final long offset,
168168
* All bytes between the given index (inclusive) and the end of the
169169
* data array are dumped.
170170
* </p>
171+
* <p>
172+
* This method uses the virtual machine's {@link Charset#defaultCharset() default charset}.
173+
* </p>
171174
*
172175
* @param data the byte array to be dumped
173176
* @param offset offset of the byte array within a larger entity

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ public static long copy(final InputStream inputStream, final OutputStream output
11121112

11131113
/**
11141114
* Copies bytes from an {@link InputStream} to chars on a
1115-
* {@link Writer} using the default character encoding of the platform.
1115+
* {@link Writer} using the virtual machine's {@link Charset#defaultCharset() default charset}.
11161116
* <p>
11171117
* This method buffers the input internally, so there is no need to use a
11181118
* {@link BufferedInputStream}.
@@ -1268,8 +1268,8 @@ public static long copy(final Reader reader, final Appendable output, final Char
12681268

12691269
/**
12701270
* Copies chars from a {@link Reader} to bytes on an
1271-
* {@link OutputStream} using the default character encoding of the
1272-
* platform, and calling flush.
1271+
* {@link OutputStream} using the the virtual machine's {@link Charset#defaultCharset() default charset},
1272+
* and calling flush.
12731273
* <p>
12741274
* This method buffers the input internally, so there is no need to use a
12751275
* {@link BufferedReader}.
@@ -2173,7 +2173,7 @@ public static List<String> readLines(final CharSequence csq) throws UncheckedIOE
21732173

21742174
/**
21752175
* Gets the contents of an {@link InputStream} as a list of Strings,
2176-
* one entry per line, using the default character encoding of the platform.
2176+
* one entry per line, using the virtual machine's {@link Charset#defaultCharset() default charset}.
21772177
* <p>
21782178
* This method buffers the input internally, so there is no need to use a
21792179
* {@link BufferedInputStream}.
@@ -2793,7 +2793,7 @@ static byte[] toByteArray(final IOTriFunction<byte[], Integer, Integer, Integer>
27932793

27942794
/**
27952795
* Gets the contents of a {@link Reader} as a {@code byte[]}
2796-
* using the default character encoding of the platform.
2796+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
27972797
* <p>
27982798
* This method buffers the input internally, so there is no need to use a
27992799
* {@link BufferedReader}.
@@ -2858,7 +2858,7 @@ public static byte[] toByteArray(final Reader reader, final String charsetName)
28582858

28592859
/**
28602860
* Gets the contents of a {@link String} as a {@code byte[]}
2861-
* using the default character encoding of the platform.
2861+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
28622862
* <p>
28632863
* This is the same as {@link String#getBytes()}.
28642864
* </p>
@@ -2919,7 +2919,7 @@ public static byte[] toByteArray(final URLConnection urlConnection) throws IOExc
29192919

29202920
/**
29212921
* Gets the contents of an {@link InputStream} as a character array
2922-
* using the default character encoding of the platform.
2922+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
29232923
* <p>
29242924
* This method buffers the input internally, so there is no need to use a
29252925
* {@link BufferedInputStream}.
@@ -3004,7 +3004,7 @@ public static char[] toCharArray(final Reader reader) throws IOException {
30043004

30053005
/**
30063006
* Converts the specified CharSequence to an input stream, encoded as bytes
3007-
* using the default character encoding of the platform.
3007+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
30083008
*
30093009
* @param input the CharSequence to convert
30103010
* @return an input stream
@@ -3049,7 +3049,7 @@ public static InputStream toInputStream(final CharSequence input, final String c
30493049

30503050
/**
30513051
* Converts the specified string to an input stream, encoded as bytes
3052-
* using the default character encoding of the platform.
3052+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
30533053
*
30543054
* @param input the string to convert
30553055
* @return an input stream
@@ -3094,7 +3094,7 @@ public static InputStream toInputStream(final String input, final String charset
30943094

30953095
/**
30963096
* Gets the contents of a {@code byte[]} as a String
3097-
* using the default character encoding of the platform.
3097+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
30983098
*
30993099
* @param input the byte array to read
31003100
* @return the requested String
@@ -3126,7 +3126,7 @@ public static String toString(final byte[] input, final String charsetName) {
31263126

31273127
/**
31283128
* Gets the contents of an {@link InputStream} as a String
3129-
* using the default character encoding of the platform.
3129+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
31303130
* <p>
31313131
* This method buffers the input internally, so there is no need to use a
31323132
* {@link BufferedInputStream}.
@@ -3255,7 +3255,7 @@ public static String toString(final Reader reader) throws IOException {
32553255
}
32563256

32573257
/**
3258-
* Gets the contents at the given URI.
3258+
* Gets the contents at the given URI using the virtual machine's {@link Charset#defaultCharset() default charset}.
32593259
*
32603260
* @param uri The URI source.
32613261
* @return The contents of the URL as a String.
@@ -3296,7 +3296,7 @@ public static String toString(final URI uri, final String charsetName) throws IO
32963296
}
32973297

32983298
/**
3299-
* Gets the contents at the given URL.
3299+
* Gets the contents at the given URL using the virtual machine's {@link Charset#defaultCharset() default charset}.
33003300
*
33013301
* @param url The URL source.
33023302
* @return The contents of the URL as a String.
@@ -3355,7 +3355,7 @@ public static void write(final byte[] data, final OutputStream output)
33553355

33563356
/**
33573357
* Writes bytes from a {@code byte[]} to chars on a {@link Writer}
3358-
* using the default character encoding of the platform.
3358+
* using the virtual machine's {@link Charset#defaultCharset() default charset}.
33593359
* <p>
33603360
* This method uses {@link String#String(byte[])}.
33613361
* </p>
@@ -3422,8 +3422,7 @@ public static void write(final byte[] data, final Writer writer, final String ch
34223422
* Writes chars from a {@code char[]} to bytes on an
34233423
* {@link OutputStream}.
34243424
* <p>
3425-
* This method uses {@link String#String(char[])} and
3426-
* {@link String#getBytes()}.
3425+
* This method uses the virtual machine's {@link Charset#defaultCharset() default charset}.
34273426
* </p>
34283427
*
34293428
* @param data the char array to write, do not modify during output,
@@ -3506,8 +3505,7 @@ public static void write(final char[] data, final Writer writer) throws IOExcept
35063505

35073506
/**
35083507
* Writes chars from a {@link CharSequence} to bytes on an
3509-
* {@link OutputStream} using the default character encoding of the
3510-
* platform.
3508+
* {@link OutputStream} using the virtual machine's {@link Charset#defaultCharset() default charset}.
35113509
* <p>
35123510
* This method uses {@link String#getBytes()}.
35133511
* </p>
@@ -3587,8 +3585,7 @@ public static void write(final CharSequence data, final Writer writer) throws IO
35873585

35883586
/**
35893587
* Writes chars from a {@link String} to bytes on an
3590-
* {@link OutputStream} using the default character encoding of the
3591-
* platform.
3588+
* {@link OutputStream} using the virtual machine's {@link Charset#defaultCharset() default charset}.
35923589
* <p>
35933590
* This method uses {@link String#getBytes()}.
35943591
* </p>
@@ -3789,8 +3786,8 @@ public static void writeChunked(final char[] data, final Writer writer) throws I
37893786

37903787
/**
37913788
* Writes the {@link #toString()} value of each item in a collection to
3792-
* an {@link OutputStream} line by line, using the default character
3793-
* encoding of the platform and the specified line ending.
3789+
* an {@link OutputStream} line by line, using the virtual machine's {@link Charset#defaultCharset() default charset}
3790+
* and the specified line ending.
37943791
*
37953792
* @param lines the lines to write, null entries produce blank lines
37963793
* @param lineEnding the line separator to use, null is system default

src/main/java/org/apache/commons/io/charset/CharsetDecoders.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public final class CharsetDecoders {
2929

3030
/**
3131
* Returns the given non-null CharsetDecoder or a new default CharsetDecoder.
32+
* <p>
33+
* Null input maps to the virtual machine's {@link Charset#defaultCharset() default charset} decoder.
34+
* </p>
3235
*
3336
* @param charsetDecoder The CharsetDecoder to test.
3437
* @return the given non-null CharsetDecoder or a new default CharsetDecoder.

src/main/java/org/apache/commons/io/charset/CharsetEncoders.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public final class CharsetEncoders {
3030

3131
/**
3232
* Returns the given non-null CharsetEncoder or a new default CharsetEncoder.
33+
* <p>
34+
* Null input maps to the virtual machine's {@link Charset#defaultCharset() default charset} decoder.
35+
* </p>
3336
*
3437
* @param charsetEncoder The CharsetEncoder to test.
3538
* @return the given non-null CharsetEncoder or a new default CharsetEncoder.

src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,11 @@ public MagicNumberFileFilter(final String magicNumber) {
215215
* </p>
216216
*
217217
* <pre>
218-
* MagicNumberFileFilter tarFileFilter =
219-
* MagicNumberFileFilter("ustar", 257);
218+
* MagicNumberFileFilter tarFileFilter = MagicNumberFileFilter("ustar", 257);
220219
* </pre>
220+
* <p>
221+
* This method uses the virtual machine's {@link Charset#defaultCharset() default charset}.
222+
* </p>
221223
*
222224
* @param magicNumber the magic number to look for in the file.
223225
* The string is converted to bytes using the platform default charset.

src/main/java/org/apache/commons/io/input/ReaderInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ private static CharsetEncoder newEncoder(final Charset charset) {
220220
private boolean endOfInput;
221221

222222
/**
223-
* Constructs a new {@link ReaderInputStream} that uses the default character encoding with a default input buffer size of
224-
* {@value IOUtils#DEFAULT_BUFFER_SIZE} characters.
223+
* Constructs a new {@link ReaderInputStream} that uses the virtual machine's {@link Charset#defaultCharset() default charset} with a default input buffer
224+
* size of {@value IOUtils#DEFAULT_BUFFER_SIZE} characters.
225225
*
226226
* @param reader the target {@link Reader}
227227
* @deprecated Use {@link ReaderInputStream#builder()} instead

src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ public static Builder builder() {
307307
private boolean trailingNewlineOfFileSkipped;
308308

309309
/**
310-
* Constructs a ReversedLinesFileReader with default block size of 4KB and the
311-
* platform's default encoding.
310+
* Constructs a ReversedLinesFileReader with default block size of 4KB and the virtual machine's {@link Charset#defaultCharset() default charset}.
312311
*
313312
* @param file the file to be read
314313
* @throws IOException if an I/O error occurs.

src/main/java/org/apache/commons/io/input/Tailer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ public String toString() {
475475

476476
private static final String RAF_READ_ONLY_MODE = "r";
477477

478-
// The default charset used for reading files
478+
/**
479+
* The the virtual machine's {@link Charset#defaultCharset() default charset} used for reading files.
480+
*/
479481
private static final Charset DEFAULT_CHARSET = Charset.defaultCharset();
480482

481483
/**

0 commit comments

Comments
 (0)