commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1483363 - in /commons/proper/io/trunk/src: main/java/org/apache/commons/io/FileUtils.java main/java/org/apache/commons/io/input/ReversedLinesFileReader.java test/java/org/apache/commons/io/input/TailerTest.java
Date Thu, 16 May 2013 13:44:26 GMT
Author: ggregory
Date: Thu May 16 13:44:25 2013
New Revision: 1483363

URL: http://svn.apache.org/r1483363
Log:
Reuse our Charsets constants.

Modified:
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java?rev=1483363&r1=1483362&r2=1483363&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java Thu May 16
13:44:25 2013
@@ -174,11 +174,6 @@ public class FileUtils {
      */
     public static final File[] EMPTY_FILE_ARRAY = new File[0];
 
-    /**
-     * The UTF-8 character set, used to decode octets in URLs.
-     */
-    private static final Charset UTF8 = Charset.forName("UTF-8");
-
     //-----------------------------------------------------------------------
     /**
      * Construct a file from the set of name elements.
@@ -884,7 +879,7 @@ public class FileUtils {
                     } finally {
                         if (bytes.position() > 0) {
                             bytes.flip();
-                            buffer.append(UTF8.decode(bytes).toString());
+                            buffer.append(Charsets.UTF_8.decode(bytes).toString());
                             bytes.clear();
                         }
                     }

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java?rev=1483363&r1=1483362&r2=1483363&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
(original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
Thu May 16 13:44:25 2013
@@ -116,7 +116,7 @@ public class ReversedLinesFileReader imp
         if (maxBytesPerChar == 1f) {
             // all one byte encodings are no problem
             byteDecrement = 1;
-        } else if (charset == Charset.forName("UTF-8")) {
+        } else if (charset == Charsets.UTF_8) {
             // UTF-8 works fine out of the box, for multibyte sequences a second UTF-8 byte
can never be a newline byte
             // http://en.wikipedia.org/wiki/UTF-8
             byteDecrement = 1;
@@ -124,11 +124,11 @@ public class ReversedLinesFileReader imp
             // Same as for UTF-8
             // http://www.herongyang.com/Unicode/JIS-Shift-JIS-Encoding.html
             byteDecrement = 1;
-        } else if (charset == Charset.forName("UTF-16BE") || charset == Charset.forName("UTF-16LE"))
{
+        } else if (charset == Charsets.UTF_16BE || charset == Charsets.UTF_16LE) {
             // UTF-16 new line sequences are not allowed as second tuple of four byte sequences,
             // however byte order has to be specified
             byteDecrement = 2;
-        } else if (charset == Charset.forName("UTF-16")) {
+        } else if (charset == Charsets.UTF_16) {
             throw new UnsupportedEncodingException("For UTF-16, you need to specify the byte
order (use UTF-16BE or UTF-16LE)");
         } else {
             throw new UnsupportedEncodingException("Encoding " + encoding + " is not supported
yet (feel free to submit a patch)");

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java?rev=1483363&r1=1483362&r2=1483363&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java Thu
May 16 13:44:25 2013
@@ -34,6 +34,7 @@ import java.util.List;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
+import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.testtools.FileBasedTestCase;
@@ -121,7 +122,7 @@ public class TailerTest extends FileBase
         final String osname = System.getProperty("os.name");
         final boolean isWindows = osname.startsWith("Windows");
         // Need to use UTF-8 to read & write the file otherwise it can be corrupted (depending
on the default charset)
-        final Charset charsetUTF8 = Charset.forName("UTF-8");
+        final Charset charsetUTF8 = Charsets.UTF_8;
         tailer = new Tailer(file, charsetUTF8, listener, delay, false, isWindows, 4096);
         final Thread thread = new Thread(tailer);
         thread.start();



Mime
View raw message