You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/12/22 14:51:14 UTC

[commons-io] branch master updated: Normalize on 'charsetName' as a parameter name since this is the named used in the JRE for Charset.forName(String).

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new e46146c  Normalize on 'charsetName' as a parameter name since this is the named used in the JRE for Charset.forName(String).
e46146c is described below

commit e46146c67026956d3f48d44be5c4df0fb78d5a42
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Dec 22 09:51:10 2019 -0500

    Normalize on 'charsetName' as a parameter name since this is the named
    used in the JRE for Charset.forName(String).
    
    - Use 'charset' instead of 'encoding' Charset parameter names.
    - Fix 1 checkstyle issue.
---
 src/main/java/org/apache/commons/io/Charsets.java  |   6 +-
 src/main/java/org/apache/commons/io/FileUtils.java | 107 ++++++-----
 src/main/java/org/apache/commons/io/IOUtils.java   | 204 ++++++++++-----------
 .../commons/io/input/ReversedLinesFileReader.java  |  10 +-
 .../commons/io/output/FileWriterWithEncoding.java  |  62 +++----
 .../commons/io/output/LockableFileWriter.java      |  30 +--
 6 files changed, 209 insertions(+), 210 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/Charsets.java b/src/main/java/org/apache/commons/io/Charsets.java
index b160b04..71f4e4e 100644
--- a/src/main/java/org/apache/commons/io/Charsets.java
+++ b/src/main/java/org/apache/commons/io/Charsets.java
@@ -97,14 +97,14 @@ public class Charsets {
     /**
      * Returns a Charset for the named charset. If the name is null, return the default Charset.
      *
-     * @param charset
+     * @param charsetName
      *            The name of the requested charset, may be null.
      * @return a Charset for the named charset
      * @throws java.nio.charset.UnsupportedCharsetException
      *             If the named charset is unavailable
      */
-    public static Charset toCharset(final String charset) {
-        return charset == null ? Charset.defaultCharset() : Charset.forName(charset);
+    public static Charset toCharset(final String charsetName) {
+        return charsetName == null ? Charset.defaultCharset() : Charset.forName(charsetName);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 05d42ca..6e5233a 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -34,7 +34,6 @@ import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
-import java.nio.file.OpenOption;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
@@ -387,7 +386,7 @@ public class FileUtils {
      * @return true if the content of the files are equal or they both don't
      * exist, false otherwise
      * @throws IOException in case of an I/O error
-     * @see org.apache.commons.io.file.PathUtils#fileContentEquals(Path,Path,OpenOption...)
+     * @see org.apache.commons.io.file.PathUtils#fileContentEquals(Path,Path,java.nio.file.OpenOption...)
      */
     public static boolean contentEquals(final File file1, final File file2) throws IOException {
         if (file1 == null && file2 == null) {
@@ -437,7 +436,7 @@ public class FileUtils {
      *
      * @param file1       the first file
      * @param file2       the second file
-     * @param charsetName the character encoding to be used.
+     * @param charsetName the name of the requested charset.
      *                    May be null, in which case the platform default is used
      * @return true if the content of the files are equal or neither exists,
      * false otherwise
@@ -1844,16 +1843,16 @@ public class FileUtils {
      * </p>
      *
      * @param file     the file to open for input, must not be {@code null}
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @return an Iterator of the lines in the file, never {@code null}
      * @throws IOException in case of an I/O error (file closed)
      * @since 1.2
      */
-    public static LineIterator lineIterator(final File file, final String encoding) throws IOException {
+    public static LineIterator lineIterator(final File file, final String charsetName) throws IOException {
         InputStream inputStream = null;
         try {
             inputStream = openInputStream(file);
-            return IOUtils.lineIterator(inputStream, encoding);
+            return IOUtils.lineIterator(inputStream, charsetName);
         } catch (final IOException | RuntimeException ex) {
             IOUtils.closeQuietly(inputStream, e -> ex.addSuppressed(e));
             throw ex;
@@ -2243,14 +2242,14 @@ public class FileUtils {
      * The file is always closed.
      *
      * @param file     the file to read, must not be {@code null}
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @return the file contents, never {@code null}
      * @throws IOException in case of an I/O error
      * @since 2.3
      */
-    public static String readFileToString(final File file, final Charset encoding) throws IOException {
+    public static String readFileToString(final File file, final Charset charsetName) throws IOException {
         try (InputStream in = openInputStream(file)) {
-            return IOUtils.toString(in, Charsets.toCharset(encoding));
+            return IOUtils.toString(in, Charsets.toCharset(charsetName));
         }
     }
 
@@ -2258,15 +2257,15 @@ public class FileUtils {
      * Reads the contents of a file into a String. The file is always closed.
      *
      * @param file     the file to read, must not be {@code null}
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @return the file contents, never {@code null}
      * @throws IOException                 in case of an I/O error
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
      * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported.
      * @since 2.3
      */
-    public static String readFileToString(final File file, final String encoding) throws IOException {
-        return readFileToString(file, Charsets.toCharset(encoding));
+    public static String readFileToString(final File file, final String charsetName) throws IOException {
+        return readFileToString(file, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2289,14 +2288,14 @@ public class FileUtils {
      * The file is always closed.
      *
      * @param file     the file to read, must not be {@code null}
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charset the charset to use, {@code null} means platform default
      * @return the list of Strings representing each line in the file, never {@code null}
      * @throws IOException in case of an I/O error
      * @since 2.3
      */
-    public static List<String> readLines(final File file, final Charset encoding) throws IOException {
+    public static List<String> readLines(final File file, final Charset charset) throws IOException {
         try (InputStream in = openInputStream(file)) {
-            return IOUtils.readLines(in, Charsets.toCharset(encoding));
+            return IOUtils.readLines(in, Charsets.toCharset(charset));
         }
     }
 
@@ -2304,15 +2303,15 @@ public class FileUtils {
      * Reads the contents of a file line by line to a List of Strings. The file is always closed.
      *
      * @param file     the file to read, must not be {@code null}
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @return the list of Strings representing each line in the file, never {@code null}
      * @throws IOException                 in case of an I/O error
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
      * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported.
      * @since 1.1
      */
-    public static List<String> readLines(final File file, final String encoding) throws IOException {
-        return readLines(file, Charsets.toCharset(encoding));
+    public static List<String> readLines(final File file, final String charsetName) throws IOException {
+        return readLines(file, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2773,12 +2772,12 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charset the name of the requested charset, {@code null} means platform default
      * @throws IOException in case of an I/O error
      * @since 2.3
      */
-    public static void write(final File file, final CharSequence data, final Charset encoding) throws IOException {
-        write(file, data, encoding, false);
+    public static void write(final File file, final CharSequence data, final Charset charset) throws IOException {
+        write(file, data, charset, false);
     }
 
     /**
@@ -2786,16 +2785,16 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charset the charset to use, {@code null} means platform default
      * @param append   if {@code true}, then the data will be added to the
      *                 end of the file rather than overwriting
      * @throws IOException in case of an I/O error
      * @since 2.3
      */
-    public static void write(final File file, final CharSequence data, final Charset encoding, final boolean append)
+    public static void write(final File file, final CharSequence data, final Charset charset, final boolean append)
             throws IOException {
         final String str = data == null ? null : data.toString();
-        writeStringToFile(file, str, encoding, append);
+        writeStringToFile(file, str, charset, append);
     }
 
     // Private method, must be invoked will a directory parameter
@@ -2805,13 +2804,13 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @throws IOException                          in case of an I/O error
      * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
      * @since 2.0
      */
-    public static void write(final File file, final CharSequence data, final String encoding) throws IOException {
-        write(file, data, encoding, false);
+    public static void write(final File file, final CharSequence data, final String charsetName) throws IOException {
+        write(file, data, charsetName, false);
     }
 
     // Internal method - does not check existence
@@ -2821,7 +2820,7 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @param append   if {@code true}, then the data will be added to the
      *                 end of the file rather than overwriting
      * @throws IOException                 in case of an I/O error
@@ -2829,9 +2828,9 @@ public class FileUtils {
      * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported by the VM
      * @since 2.1
      */
-    public static void write(final File file, final CharSequence data, final String encoding, final boolean append)
+    public static void write(final File file, final CharSequence data, final String charsetName, final boolean append)
             throws IOException {
-        write(file, data, Charsets.toCharset(encoding), append);
+        write(file, data, Charsets.toCharset(charsetName), append);
     }
 
     /**
@@ -2982,15 +2981,15 @@ public class FileUtils {
      * </p>
      *
      * @param file     the file to write to
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @param lines    the lines to write, {@code null} entries produce blank lines
      * @throws IOException                          in case of an I/O error
      * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
      * @since 1.1
      */
-    public static void writeLines(final File file, final String encoding, final Collection<?> lines)
+    public static void writeLines(final File file, final String charsetName, final Collection<?> lines)
             throws IOException {
-        writeLines(file, encoding, lines, null, false);
+        writeLines(file, charsetName, lines, null, false);
     }
 
     /**
@@ -2999,7 +2998,7 @@ public class FileUtils {
      * The specified character encoding and the default line ending will be used.
      *
      * @param file     the file to write to
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @param lines    the lines to write, {@code null} entries produce blank lines
      * @param append   if {@code true}, then the lines will be added to the
      *                 end of the file rather than overwriting
@@ -3007,9 +3006,9 @@ public class FileUtils {
      * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
      * @since 2.1
      */
-    public static void writeLines(final File file, final String encoding, final Collection<?> lines,
+    public static void writeLines(final File file, final String charsetName, final Collection<?> lines,
                                   final boolean append) throws IOException {
-        writeLines(file, encoding, lines, null, append);
+        writeLines(file, charsetName, lines, null, append);
     }
 
     /**
@@ -3022,16 +3021,16 @@ public class FileUtils {
      * </p>
      *
      * @param file       the file to write to
-     * @param encoding   the encoding to use, {@code null} means platform default
+     * @param charsetName   the name of the requested charset, {@code null} means platform default
      * @param lines      the lines to write, {@code null} entries produce blank lines
      * @param lineEnding the line separator to use, {@code null} is system default
      * @throws IOException                          in case of an I/O error
      * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
      * @since 1.1
      */
-    public static void writeLines(final File file, final String encoding, final Collection<?> lines,
+    public static void writeLines(final File file, final String charsetName, final Collection<?> lines,
                                   final String lineEnding) throws IOException {
-        writeLines(file, encoding, lines, lineEnding, false);
+        writeLines(file, charsetName, lines, lineEnding, false);
     }
 
     /**
@@ -3040,7 +3039,7 @@ public class FileUtils {
      * The specified character encoding and the line ending will be used.
      *
      * @param file       the file to write to
-     * @param encoding   the encoding to use, {@code null} means platform default
+     * @param charsetName   the name of the requested charset, {@code null} means platform default
      * @param lines      the lines to write, {@code null} entries produce blank lines
      * @param lineEnding the line separator to use, {@code null} is system default
      * @param append     if {@code true}, then the lines will be added to the
@@ -3049,10 +3048,10 @@ public class FileUtils {
      * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
      * @since 2.1
      */
-    public static void writeLines(final File file, final String encoding, final Collection<?> lines,
+    public static void writeLines(final File file, final String charsetName, final Collection<?> lines,
                                   final String lineEnding, final boolean append) throws IOException {
         try (OutputStream out = new BufferedOutputStream(openOutputStream(file, append))) {
-            IOUtils.writeLines(lines, lineEnding, out, encoding);
+            IOUtils.writeLines(lines, lineEnding, out, charsetName);
         }
     }
 
@@ -3094,14 +3093,14 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charset the charset to use, {@code null} means platform default
      * @throws IOException                          in case of an I/O error
      * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
      * @since 2.4
      */
-    public static void writeStringToFile(final File file, final String data, final Charset encoding)
+    public static void writeStringToFile(final File file, final String data, final Charset charset)
             throws IOException {
-        writeStringToFile(file, data, encoding, false);
+        writeStringToFile(file, data, charset, false);
     }
 
     /**
@@ -3109,16 +3108,16 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charset the charset to use, {@code null} means platform default
      * @param append   if {@code true}, then the String will be added to the
      *                 end of the file rather than overwriting
      * @throws IOException in case of an I/O error
      * @since 2.3
      */
-    public static void writeStringToFile(final File file, final String data, final Charset encoding,
+    public static void writeStringToFile(final File file, final String data, final Charset charset,
                                          final boolean append) throws IOException {
         try (OutputStream out = openOutputStream(file, append)) {
-            IOUtils.write(data, out, encoding);
+            IOUtils.write(data, out, charset);
         }
     }
 
@@ -3131,12 +3130,12 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @throws IOException                          in case of an I/O error
      * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
      */
-    public static void writeStringToFile(final File file, final String data, final String encoding) throws IOException {
-        writeStringToFile(file, data, encoding, false);
+    public static void writeStringToFile(final File file, final String data, final String charsetName) throws IOException {
+        writeStringToFile(file, data, charsetName, false);
     }
 
     /**
@@ -3144,7 +3143,7 @@ public class FileUtils {
      *
      * @param file     the file to write
      * @param data     the content to write to the file
-     * @param encoding the encoding to use, {@code null} means platform default
+     * @param charsetName the name of the requested charset, {@code null} means platform default
      * @param append   if {@code true}, then the String will be added to the
      *                 end of the file rather than overwriting
      * @throws IOException                 in case of an I/O error
@@ -3152,9 +3151,9 @@ public class FileUtils {
      * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported by the VM
      * @since 2.1
      */
-    public static void writeStringToFile(final File file, final String data, final String encoding,
+    public static void writeStringToFile(final File file, final String data, final String charsetName,
                                          final boolean append) throws IOException {
-        writeStringToFile(file, data, Charsets.toCharset(encoding), append);
+        writeStringToFile(file, data, Charsets.toCharset(charsetName), append);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java
index 4f84559..f484c03 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -884,14 +884,14 @@ public class IOUtils {
      *
      * @param input the <code>InputStream</code> to read from
      * @param output the <code>Writer</code> to write to
-     * @param inputEncoding the encoding to use for the input stream, null means platform default
+     * @param inputCharset the charser to use for the input stream, null means platform default
      * @throws NullPointerException if the input or output is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static void copy(final InputStream input, final Writer output, final Charset inputEncoding)
+    public static void copy(final InputStream input, final Writer output, final Charset inputCharset)
             throws IOException {
-        final InputStreamReader in = new InputStreamReader(input, Charsets.toCharset(inputEncoding));
+        final InputStreamReader in = new InputStreamReader(input, Charsets.toCharset(inputCharset));
         copy(in, output);
     }
 
@@ -909,7 +909,7 @@ public class IOUtils {
      *
      * @param input the <code>InputStream</code> to read from
      * @param output the <code>Writer</code> to write to
-     * @param inputEncoding the encoding to use for the InputStream, null means platform default
+     * @param inputCharsetName the name of the requested charset for the InputStream, null means platform default
      * @throws NullPointerException                         if the input or output is null
      * @throws IOException                                  if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -917,9 +917,9 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.1
      */
-    public static void copy(final InputStream input, final Writer output, final String inputEncoding)
+    public static void copy(final InputStream input, final Writer output, final String inputCharsetName)
             throws IOException {
-        copy(input, output, Charsets.toCharset(inputEncoding));
+        copy(input, output, Charsets.toCharset(inputCharsetName));
     }
 
     /**
@@ -1014,14 +1014,14 @@ public class IOUtils {
      *
      * @param input the <code>Reader</code> to read from
      * @param output the <code>OutputStream</code> to write to
-     * @param outputEncoding the encoding to use for the OutputStream, null means platform default
+     * @param outputCharset the charset to use for the OutputStream, null means platform default
      * @throws NullPointerException if the input or output is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static void copy(final Reader input, final OutputStream output, final Charset outputEncoding)
+    public static void copy(final Reader input, final OutputStream output, final Charset outputCharset)
             throws IOException {
-        final OutputStreamWriter out = new OutputStreamWriter(output, Charsets.toCharset(outputEncoding));
+        final OutputStreamWriter out = new OutputStreamWriter(output, Charsets.toCharset(outputCharset));
         copy(input, out);
         // XXX Unless anyone is planning on rewriting OutputStreamWriter,
         // we have to flush here.
@@ -1046,7 +1046,7 @@ public class IOUtils {
      *
      * @param input the <code>Reader</code> to read from
      * @param output the <code>OutputStream</code> to write to
-     * @param outputEncoding the encoding to use for the OutputStream, null means platform default
+     * @param outputCharsetName the name of the requested charset for the OutputStream, null means platform default
      * @throws NullPointerException                         if the input or output is null
      * @throws IOException                                  if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -1054,9 +1054,9 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.1
      */
-    public static void copy(final Reader input, final OutputStream output, final String outputEncoding)
+    public static void copy(final Reader input, final OutputStream output, final String outputCharsetName)
             throws IOException {
-        copy(input, output, Charsets.toCharset(outputEncoding));
+        copy(input, output, Charsets.toCharset(outputCharsetName));
     }
 
     /**
@@ -1393,14 +1393,14 @@ public class IOUtils {
      * </pre>
      *
      * @param input the <code>InputStream</code> to read from, not null
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return an Iterator of the lines in the reader, never null
      * @throws IllegalArgumentException if the input is null
      * @throws IOException              if an I/O error occurs, such as if the encoding is invalid
      * @since 2.3
      */
-    public static LineIterator lineIterator(final InputStream input, final Charset encoding) throws IOException {
-        return new LineIterator(new InputStreamReader(input, Charsets.toCharset(encoding)));
+    public static LineIterator lineIterator(final InputStream input, final Charset charset) throws IOException {
+        return new LineIterator(new InputStreamReader(input, Charsets.toCharset(charset)));
     }
 
     /**
@@ -1427,7 +1427,7 @@ public class IOUtils {
      * </pre>
      *
      * @param input the <code>InputStream</code> to read from, not null
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the encoding to use, null means platform default
      * @return an Iterator of the lines in the reader, never null
      * @throws IllegalArgumentException                     if the input is null
      * @throws IOException                                  if an I/O error occurs, such as if the encoding is invalid
@@ -1436,8 +1436,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.2
      */
-    public static LineIterator lineIterator(final InputStream input, final String encoding) throws IOException {
-        return lineIterator(input, Charsets.toCharset(encoding));
+    public static LineIterator lineIterator(final InputStream input, final String charsetName) throws IOException {
+        return lineIterator(input, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -1738,14 +1738,14 @@ public class IOUtils {
      * <code>BufferedInputStream</code>.
      *
      * @param input the <code>InputStream</code> to read from, not null
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return the list of Strings, never null
      * @throws NullPointerException if the input is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static List<String> readLines(final InputStream input, final Charset encoding) throws IOException {
-        final InputStreamReader reader = new InputStreamReader(input, Charsets.toCharset(encoding));
+    public static List<String> readLines(final InputStream input, final Charset charset) throws IOException {
+        final InputStreamReader reader = new InputStreamReader(input, Charsets.toCharset(charset));
         return readLines(reader);
     }
 
@@ -1760,7 +1760,7 @@ public class IOUtils {
      * <code>BufferedInputStream</code>.
      *
      * @param input the <code>InputStream</code> to read from, not null
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @return the list of Strings, never null
      * @throws NullPointerException                         if the input is null
      * @throws IOException                                  if an I/O error occurs
@@ -1769,8 +1769,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.1
      */
-    public static List<String> readLines(final InputStream input, final String encoding) throws IOException {
-        return readLines(input, Charsets.toCharset(encoding));
+    public static List<String> readLines(final InputStream input, final String charsetName) throws IOException {
+        return readLines(input, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -1844,14 +1844,14 @@ public class IOUtils {
      * </p>
      *
      * @param name     name of the desired resource
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return the requested String
      * @throws IOException if an I/O error occurs
      *
      * @since 2.6
      */
-    public static String resourceToString(final String name, final Charset encoding) throws IOException {
-        return resourceToString(name, encoding, null);
+    public static String resourceToString(final String name, final Charset charset) throws IOException {
+        return resourceToString(name, charset, null);
     }
 
     /**
@@ -1864,15 +1864,15 @@ public class IOUtils {
      * </p>
      *
      * @param name     name of the desired resource
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @param classLoader the class loader that the resolution of the resource is delegated to
      * @return the requested String
      * @throws IOException if an I/O error occurs
      *
      * @since 2.6
      */
-    public static String resourceToString(final String name, final Charset encoding, final ClassLoader classLoader) throws IOException {
-        return toString(resourceToURL(name, classLoader), encoding);
+    public static String resourceToString(final String name, final Charset charset, final ClassLoader classLoader) throws IOException {
+        return toString(resourceToURL(name, classLoader), charset);
     }
 
     /**
@@ -2303,15 +2303,15 @@ public class IOUtils {
      * <code>BufferedReader</code>.
      *
      * @param input the <code>Reader</code> to read from
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return the requested byte array
      * @throws NullPointerException if the input is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static byte[] toByteArray(final Reader input, final Charset encoding) throws IOException {
+    public static byte[] toByteArray(final Reader input, final Charset charset) throws IOException {
         try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
-            copy(input, output, encoding);
+            copy(input, output, charset);
             return output.toByteArray();
         }
     }
@@ -2327,7 +2327,7 @@ public class IOUtils {
      * <code>BufferedReader</code>.
      *
      * @param input the <code>Reader</code> to read from
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @return the requested byte array
      * @throws NullPointerException                         if the input is null
      * @throws IOException                                  if an I/O error occurs
@@ -2336,8 +2336,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.1
      */
-    public static byte[] toByteArray(final Reader input, final String encoding) throws IOException {
-        return toByteArray(input, Charsets.toCharset(encoding));
+    public static byte[] toByteArray(final Reader input, final String charsetName) throws IOException {
+        return toByteArray(input, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2431,16 +2431,16 @@ public class IOUtils {
      * <code>BufferedInputStream</code>.
      *
      * @param is the <code>InputStream</code> to read from
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return the requested character array
      * @throws NullPointerException if the input is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static char[] toCharArray(final InputStream is, final Charset encoding)
+    public static char[] toCharArray(final InputStream is, final Charset charset)
             throws IOException {
         final CharArrayWriter output = new CharArrayWriter();
-        copy(is, output, encoding);
+        copy(is, output, charset);
         return output.toCharArray();
     }
 
@@ -2455,7 +2455,7 @@ public class IOUtils {
      * <code>BufferedInputStream</code>.
      *
      * @param is the <code>InputStream</code> to read from
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @return the requested character array
      * @throws NullPointerException                         if the input is null
      * @throws IOException                                  if an I/O error occurs
@@ -2464,8 +2464,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.1
      */
-    public static char[] toCharArray(final InputStream is, final String encoding) throws IOException {
-        return toCharArray(is, Charsets.toCharset(encoding));
+    public static char[] toCharArray(final InputStream is, final String charsetName) throws IOException {
+        return toCharArray(is, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2505,12 +2505,12 @@ public class IOUtils {
      * using the specified character encoding.
      *
      * @param input the CharSequence to convert
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return an input stream
      * @since 2.3
      */
-    public static InputStream toInputStream(final CharSequence input, final Charset encoding) {
-        return toInputStream(input.toString(), encoding);
+    public static InputStream toInputStream(final CharSequence input, final Charset charset) {
+        return toInputStream(input.toString(), charset);
     }
 
     /**
@@ -2521,7 +2521,7 @@ public class IOUtils {
      * <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
      *
      * @param input the CharSequence to convert
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @return an input stream
      * @throws IOException                                  if the encoding is invalid
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -2529,8 +2529,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 2.0
      */
-    public static InputStream toInputStream(final CharSequence input, final String encoding) throws IOException {
-        return toInputStream(input, Charsets.toCharset(encoding));
+    public static InputStream toInputStream(final CharSequence input, final String charsetName) throws IOException {
+        return toInputStream(input, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2552,12 +2552,12 @@ public class IOUtils {
      * using the specified character encoding.
      *
      * @param input the string to convert
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return an input stream
      * @since 2.3
      */
-    public static InputStream toInputStream(final String input, final Charset encoding) {
-        return new ByteArrayInputStream(input.getBytes(Charsets.toCharset(encoding)));
+    public static InputStream toInputStream(final String input, final Charset charset) {
+        return new ByteArrayInputStream(input.getBytes(Charsets.toCharset(charset)));
     }
 
     /**
@@ -2568,7 +2568,7 @@ public class IOUtils {
      * <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
      *
      * @param input the string to convert
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @return an input stream
      * @throws IOException                                  if the encoding is invalid
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -2576,8 +2576,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.1
      */
-    public static InputStream toInputStream(final String input, final String encoding) throws IOException {
-        final byte[] bytes = input.getBytes(Charsets.toCharset(encoding));
+    public static InputStream toInputStream(final String input, final String charsetName) throws IOException {
+        final byte[] bytes = input.getBytes(Charsets.toCharset(charsetName));
         return new ByteArrayInputStream(bytes);
     }
 
@@ -2605,13 +2605,13 @@ public class IOUtils {
      * <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
      *
      * @param input the byte array to read from
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @return the requested String
      * @throws NullPointerException if the input is null
      * @throws IOException          if an I/O error occurs (never occurs)
      */
-    public static String toString(final byte[] input, final String encoding) throws IOException {
-        return new String(input, Charsets.toCharset(encoding));
+    public static String toString(final byte[] input, final String charsetName) throws IOException {
+        return new String(input, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2641,15 +2641,15 @@ public class IOUtils {
      * </p>
      *
      * @param input the <code>InputStream</code> to read from
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @return the requested String
      * @throws NullPointerException if the input is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static String toString(final InputStream input, final Charset encoding) throws IOException {
+    public static String toString(final InputStream input, final Charset charset) throws IOException {
         try (final StringBuilderWriter sw = new StringBuilderWriter()) {
-            copy(input, sw, encoding);
+            copy(input, sw, charset);
             return sw.toString();
         }
     }
@@ -2665,7 +2665,7 @@ public class IOUtils {
      * <code>BufferedInputStream</code>.
      *
      * @param input the <code>InputStream</code> to read from
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @return the requested String
      * @throws NullPointerException                         if the input is null
      * @throws IOException                                  if an I/O error occurs
@@ -2673,9 +2673,9 @@ public class IOUtils {
      *                                                      .UnsupportedEncodingException} in version 2.2 if the
      *                                                      encoding is not supported.
      */
-    public static String toString(final InputStream input, final String encoding)
+    public static String toString(final InputStream input, final String charsetName)
             throws IOException {
-        return toString(input, Charsets.toCharset(encoding));
+        return toString(input, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2727,7 +2727,7 @@ public class IOUtils {
      * Gets the contents at the given URI.
      *
      * @param uri The URI source.
-     * @param encoding The encoding name for the URL contents.
+     * @param charsetName The encoding name for the URL contents.
      * @return The contents of the URL as a String.
      * @throws IOException                                  if an I/O exception occurs.
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -2735,8 +2735,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 2.1
      */
-    public static String toString(final URI uri, final String encoding) throws IOException {
-        return toString(uri, Charsets.toCharset(encoding));
+    public static String toString(final URI uri, final String charsetName) throws IOException {
+        return toString(uri, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2772,7 +2772,7 @@ public class IOUtils {
      * Gets the contents at the given URL.
      *
      * @param url The URL source.
-     * @param encoding The encoding name for the URL contents.
+     * @param charsetName The encoding name for the URL contents.
      * @return The contents of the URL as a String.
      * @throws IOException                                  if an I/O exception occurs.
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -2780,8 +2780,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 2.1
      */
-    public static String toString(final URL url, final String encoding) throws IOException {
-        return toString(url, Charsets.toCharset(encoding));
+    public static String toString(final URL url, final String charsetName) throws IOException {
+        return toString(url, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2829,14 +2829,14 @@ public class IOUtils {
      * @param data the byte array to write, do not modify during output,
      * null ignored
      * @param output the <code>Writer</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @throws NullPointerException if output is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static void write(final byte[] data, final Writer output, final Charset encoding) throws IOException {
+    public static void write(final byte[] data, final Writer output, final Charset charset) throws IOException {
         if (data != null) {
-            output.write(new String(data, Charsets.toCharset(encoding)));
+            output.write(new String(data, Charsets.toCharset(charset)));
         }
     }
 
@@ -2852,7 +2852,7 @@ public class IOUtils {
      * @param data the byte array to write, do not modify during output,
      * null ignored
      * @param output the <code>Writer</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @throws NullPointerException                         if output is null
      * @throws IOException                                  if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -2860,8 +2860,8 @@ public class IOUtils {
      *                                                      encoding is not supported.
      * @since 1.1
      */
-    public static void write(final byte[] data, final Writer output, final String encoding) throws IOException {
-        write(data, output, Charsets.toCharset(encoding));
+    public static void write(final byte[] data, final Writer output, final String charsetName) throws IOException {
+        write(data, output, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2895,14 +2895,14 @@ public class IOUtils {
      * @param data the char array to write, do not modify during output,
      * null ignored
      * @param output the <code>OutputStream</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the chartset to use, null means platform default
      * @throws NullPointerException if output is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static void write(final char[] data, final OutputStream output, final Charset encoding) throws IOException {
+    public static void write(final char[] data, final OutputStream output, final Charset charset) throws IOException {
         if (data != null) {
-            output.write(new String(data).getBytes(Charsets.toCharset(encoding)));
+            output.write(new String(data).getBytes(Charsets.toCharset(charset)));
         }
     }
 
@@ -2919,16 +2919,16 @@ public class IOUtils {
      * @param data the char array to write, do not modify during output,
      * null ignored
      * @param output the <code>OutputStream</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @throws NullPointerException                         if output is null
      * @throws IOException                                  if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
      * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported.
      * @since 1.1
      */
-    public static void write(final char[] data, final OutputStream output, final String encoding)
+    public static void write(final char[] data, final OutputStream output, final String charsetName)
             throws IOException {
-        write(data, output, Charsets.toCharset(encoding));
+        write(data, output, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -2975,15 +2975,15 @@ public class IOUtils {
      *
      * @param data the <code>CharSequence</code> to write, null ignored
      * @param output the <code>OutputStream</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @throws NullPointerException if output is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static void write(final CharSequence data, final OutputStream output, final Charset encoding)
+    public static void write(final CharSequence data, final OutputStream output, final Charset charset)
             throws IOException {
         if (data != null) {
-            write(data.toString(), output, encoding);
+            write(data.toString(), output, charset);
         }
     }
 
@@ -2998,16 +2998,16 @@ public class IOUtils {
      *
      * @param data the <code>CharSequence</code> to write, null ignored
      * @param output the <code>OutputStream</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @throws NullPointerException        if output is null
      * @throws IOException                 if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
      * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported.
      * @since 2.0
      */
-    public static void write(final CharSequence data, final OutputStream output, final String encoding)
+    public static void write(final CharSequence data, final OutputStream output, final String charsetName)
             throws IOException {
-        write(data, output, Charsets.toCharset(encoding));
+        write(data, output, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -3054,14 +3054,14 @@ public class IOUtils {
      *
      * @param data the <code>String</code> to write, null ignored
      * @param output the <code>OutputStream</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @throws NullPointerException if output is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
-    public static void write(final String data, final OutputStream output, final Charset encoding) throws IOException {
+    public static void write(final String data, final OutputStream output, final Charset charset) throws IOException {
         if (data != null) {
-            output.write(data.getBytes(Charsets.toCharset(encoding)));
+            output.write(data.getBytes(Charsets.toCharset(charset)));
         }
     }
 
@@ -3076,16 +3076,16 @@ public class IOUtils {
      *
      * @param data the <code>String</code> to write, null ignored
      * @param output the <code>OutputStream</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @throws NullPointerException        if output is null
      * @throws IOException                 if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
      * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported.
      * @since 1.1
      */
-    public static void write(final String data, final OutputStream output, final String encoding)
+    public static void write(final String data, final OutputStream output, final String charsetName)
             throws IOException {
-        write(data, output, Charsets.toCharset(encoding));
+        write(data, output, Charsets.toCharset(charsetName));
     }
 
     /**
@@ -3134,7 +3134,7 @@ public class IOUtils {
      *
      * @param data the <code>StringBuffer</code> to write, null ignored
      * @param output the <code>OutputStream</code> to write to
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @throws NullPointerException        if output is null
      * @throws IOException                 if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -3143,10 +3143,10 @@ public class IOUtils {
      * @deprecated replaced by write(CharSequence, OutputStream, String)
      */
     @Deprecated
-    public static void write(final StringBuffer data, final OutputStream output, final String encoding)
+    public static void write(final StringBuffer data, final OutputStream output, final String charsetName)
             throws IOException {
         if (data != null) {
-            output.write(data.toString().getBytes(Charsets.toCharset(encoding)));
+            output.write(data.toString().getBytes(Charsets.toCharset(charsetName)));
         }
     }
 
@@ -3246,20 +3246,20 @@ public class IOUtils {
      * @param lines the lines to write, null entries produce blank lines
      * @param lineEnding the line separator to use, null is system default
      * @param output the <code>OutputStream</code> to write to, not null, not closed
-     * @param encoding the encoding to use, null means platform default
+     * @param charset the charset to use, null means platform default
      * @throws NullPointerException if the output is null
      * @throws IOException          if an I/O error occurs
      * @since 2.3
      */
     public static void writeLines(final Collection<?> lines, String lineEnding, final OutputStream output,
-                                  final Charset encoding) throws IOException {
+                                  final Charset charset) throws IOException {
         if (lines == null) {
             return;
         }
         if (lineEnding == null) {
             lineEnding = LINE_SEPARATOR;
         }
-        final Charset cs = Charsets.toCharset(encoding);
+        final Charset cs = Charsets.toCharset(charset);
         for (final Object line : lines) {
             if (line != null) {
                 output.write(line.toString().getBytes(cs));
@@ -3279,7 +3279,7 @@ public class IOUtils {
      * @param lines the lines to write, null entries produce blank lines
      * @param lineEnding the line separator to use, null is system default
      * @param output the <code>OutputStream</code> to write to, not null, not closed
-     * @param encoding the encoding to use, null means platform default
+     * @param charsetName the name of the requested charset, null means platform default
      * @throws NullPointerException                         if the output is null
      * @throws IOException                                  if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
@@ -3288,8 +3288,8 @@ public class IOUtils {
      * @since 1.1
      */
     public static void writeLines(final Collection<?> lines, final String lineEnding,
-                                  final OutputStream output, final String encoding) throws IOException {
-        writeLines(lines, lineEnding, output, Charsets.toCharset(encoding));
+                                  final OutputStream output, final String charsetName) throws IOException {
+        writeLines(lines, lineEnding, output, Charsets.toCharset(charsetName));
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java b/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
index e126bfc..b351a64 100644
--- a/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
+++ b/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
@@ -78,7 +78,7 @@ public class ReversedLinesFileReader implements Closeable {
      *
      * @param file
      *            the file to be read
-     * @param charset the encoding to use
+     * @param charset the charset to use
      * @throws IOException  if an I/O error occurs
      * @since 2.5
      */
@@ -92,7 +92,7 @@ public class ReversedLinesFileReader implements Closeable {
      *
      * @param file
      *            the file to be read
-     * @param charset the encoding to use
+     * @param charset the charset to use
      * @throws IOException  if an I/O error occurs
      * @since 2.7
      */
@@ -211,15 +211,15 @@ public class ReversedLinesFileReader implements Closeable {
      * @param blockSize
      *            size of the internal buffer (for ideal performance this should
      *            match with the block size of the underlying file system).
-     * @param encoding
+     * @param charsetName
      *            the encoding of the file
      * @throws IOException  if an I/O error occurs
      * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link UnsupportedEncodingException} in
      * version 2.2 if the encoding is not supported.
      * @since 2.7
      */
-    public ReversedLinesFileReader(final Path file, final int blockSize, final String encoding) throws IOException {
-        this(file, blockSize, Charsets.toCharset(encoding));
+    public ReversedLinesFileReader(final Path file, final int blockSize, final String charsetName) throws IOException {
+        this(file, blockSize, Charsets.toCharset(charsetName));
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java b/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
index 0af67b9..b01d985 100644
--- a/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
+++ b/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
@@ -58,52 +58,52 @@ public class FileWriterWithEncoding extends Writer {
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param fileName  the name of the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charsetName  the name of the requested charset, not null
      * @throws NullPointerException if the file name or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final String fileName, final String encoding) throws IOException {
-        this(new File(fileName), encoding, false);
+    public FileWriterWithEncoding(final String fileName, final String charsetName) throws IOException {
+        this(new File(fileName), charsetName, false);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param fileName  the name of the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charsetName  the name of the requested charset, not null
      * @param append  true if content should be appended, false to overwrite
      * @throws NullPointerException if the file name or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final String fileName, final String encoding, final boolean append)
+    public FileWriterWithEncoding(final String fileName, final String charsetName, final boolean append)
             throws IOException {
-        this(new File(fileName), encoding, append);
+        this(new File(fileName), charsetName, append);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param fileName  the name of the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charset  the charset to use, not null
      * @throws NullPointerException if the file name or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final String fileName, final Charset encoding) throws IOException {
-        this(new File(fileName), encoding, false);
+    public FileWriterWithEncoding(final String fileName, final Charset charset) throws IOException {
+        this(new File(fileName), charset, false);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param fileName  the name of the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charset  the encoding to use, not null
      * @param append  true if content should be appended, false to overwrite
      * @throws NullPointerException if the file name or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final String fileName, final Charset encoding, final boolean append)
+    public FileWriterWithEncoding(final String fileName, final Charset charset, final boolean append)
             throws IOException {
-        this(new File(fileName), encoding, append);
+        this(new File(fileName), charset, append);
     }
 
     /**
@@ -122,59 +122,59 @@ public class FileWriterWithEncoding extends Writer {
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param fileName  the name of the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charsetEncoder  the encoding to use, not null
      * @param append  true if content should be appended, false to overwrite
      * @throws NullPointerException if the file name or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final String fileName, final CharsetEncoder encoding, final boolean append)
+    public FileWriterWithEncoding(final String fileName, final CharsetEncoder charsetEncoder, final boolean append)
             throws IOException {
-        this(new File(fileName), encoding, append);
+        this(new File(fileName), charsetEncoder, append);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charsetName  the name of the requested charset, not null
      * @throws NullPointerException if the file or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final File file, final String encoding) throws IOException {
-        this(file, encoding, false);
+    public FileWriterWithEncoding(final File file, final String charsetName) throws IOException {
+        this(file, charsetName, false);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charsetName  the name of the requested charset, not null
      * @param append  true if content should be appended, false to overwrite
      * @throws NullPointerException if the file or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final File file, final String encoding, final boolean append) throws IOException {
+    public FileWriterWithEncoding(final File file, final String charsetName, final boolean append) throws IOException {
         super();
-        this.out = initWriter(file, encoding, append);
+        this.out = initWriter(file, charsetName, append);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charset  the encoding to use, not null
      * @throws NullPointerException if the file or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final File file, final Charset encoding) throws IOException {
-        this(file, encoding, false);
+    public FileWriterWithEncoding(final File file, final Charset charset) throws IOException {
+        this(file, charset, false);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param encoding  the name of the requested charset, not null
      * @param append  true if content should be appended, false to overwrite
      * @throws NullPointerException if the file or encoding is null
      * @throws IOException in case of an I/O error
@@ -188,27 +188,27 @@ public class FileWriterWithEncoding extends Writer {
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charsetEncoder  the encoding to use, not null
      * @throws NullPointerException if the file or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final File file, final CharsetEncoder encoding) throws IOException {
-        this(file, encoding, false);
+    public FileWriterWithEncoding(final File file, final CharsetEncoder charsetEncoder) throws IOException {
+        this(file, charsetEncoder, false);
     }
 
     /**
      * Constructs a FileWriterWithEncoding with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, not null
+     * @param charsetEncoder  the encoding to use, not null
      * @param append  true if content should be appended, false to overwrite
      * @throws NullPointerException if the file or encoding is null
      * @throws IOException in case of an I/O error
      */
-    public FileWriterWithEncoding(final File file, final CharsetEncoder encoding, final boolean append)
+    public FileWriterWithEncoding(final File file, final CharsetEncoder charsetEncoder, final boolean append)
             throws IOException {
         super();
-        this.out = initWriter(file, encoding, append);
+        this.out = initWriter(file, charsetEncoder, append);
     }
 
     //-----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/output/LockableFileWriter.java b/src/main/java/org/apache/commons/io/output/LockableFileWriter.java
index f2f8f8f..0d46fd3 100644
--- a/src/main/java/org/apache/commons/io/output/LockableFileWriter.java
+++ b/src/main/java/org/apache/commons/io/output/LockableFileWriter.java
@@ -137,42 +137,42 @@ public class LockableFileWriter extends Writer {
      * Constructs a LockableFileWriter with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, null means platform default
+     * @param charset  the charset to use, null means platform default
      * @throws NullPointerException if the file is null
      * @throws IOException in case of an I/O error
      * @since 2.3
      */
-    public LockableFileWriter(final File file, final Charset encoding) throws IOException {
-        this(file, encoding, false, null);
+    public LockableFileWriter(final File file, final Charset charset) throws IOException {
+        this(file, charset, false, null);
     }
 
     /**
      * Constructs a LockableFileWriter with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, null means platform default
+     * @param charsetName  the name of the requested charset, null means platform default
      * @throws NullPointerException if the file is null
      * @throws IOException in case of an I/O error
      * @throws java.nio.charset.UnsupportedCharsetException
      *             thrown instead of {@link java.io.UnsupportedEncodingException} in version 2.2 if the encoding is not
      *             supported.
      */
-    public LockableFileWriter(final File file, final String encoding) throws IOException {
-        this(file, encoding, false, null);
+    public LockableFileWriter(final File file, final String charsetName) throws IOException {
+        this(file, charsetName, false, null);
     }
 
     /**
      * Constructs a LockableFileWriter with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, null means platform default
+     * @param charset  the name of the requested charset, null means platform default
      * @param append  true if content should be appended, false to overwrite
      * @param lockDir  the directory in which the lock file should be held
      * @throws NullPointerException if the file is null
      * @throws IOException in case of an I/O error
      * @since 2.3
      */
-    public LockableFileWriter(File file, final Charset encoding, final boolean append,
+    public LockableFileWriter(File file, final Charset charset, final boolean append,
             String lockDir) throws IOException {
         super();
         // init file to create/append
@@ -197,14 +197,14 @@ public class LockableFileWriter extends Writer {
         createLock();
 
         // init wrapped writer
-        out = initWriter(file, encoding, append);
+        out = initWriter(file, charset, append);
     }
 
     /**
      * Constructs a LockableFileWriter with a file encoding.
      *
      * @param file  the file to write to, not null
-     * @param encoding  the encoding to use, null means platform default
+     * @param charsetName  the encoding to use, null means platform default
      * @param append  true if content should be appended, false to overwrite
      * @param lockDir  the directory in which the lock file should be held
      * @throws NullPointerException if the file is null
@@ -213,9 +213,9 @@ public class LockableFileWriter extends Writer {
      *             thrown instead of {@link java.io.UnsupportedEncodingException} in version 2.2 if the encoding is not
      *             supported.
      */
-    public LockableFileWriter(final File file, final String encoding, final boolean append,
+    public LockableFileWriter(final File file, final String charsetName, final boolean append,
             final String lockDir) throws IOException {
-        this(file, Charsets.toCharset(encoding), append, lockDir);
+        this(file, Charsets.toCharset(charsetName), append, lockDir);
     }
 
     //-----------------------------------------------------------------------
@@ -257,16 +257,16 @@ public class LockableFileWriter extends Writer {
      * Ensure that a cleanup occurs if the writer creation fails.
      *
      * @param file  the file to be accessed
-     * @param encoding  the encoding to use
+     * @param charset  the charset to use
      * @param append  true to append
      * @return The initialised writer
      * @throws IOException if an error occurs
      */
-    private Writer initWriter(final File file, final Charset encoding, final boolean append) throws IOException {
+    private Writer initWriter(final File file, final Charset charset, final boolean append) throws IOException {
         final boolean fileExistedAlready = file.exists();
         try {
             return new OutputStreamWriter(new FileOutputStream(file.getAbsolutePath(), append),
-                                          Charsets.toCharset(encoding));
+                                          Charsets.toCharset(charset));
 
         } catch (final IOException | RuntimeException ex) {
             FileUtils.deleteQuietly(lockFile);