jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [4/5] jena git commit: Use commons FilenameUtils
Date Tue, 05 Jun 2018 19:30:01 GMT
Use commons FilenameUtils


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/5304fa41
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/5304fa41
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/5304fa41

Branch: refs/heads/master
Commit: 5304fa41fbda34b0bf10e682e2a7ef4d09d2803f
Parents: 74163ea
Author: Andy Seaborne <andy@apache.org>
Authored: Mon Jun 4 17:03:19 2018 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Mon Jun 4 17:22:08 2018 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/jena/atlas/io/IO.java     | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/5304fa41/jena-base/src/main/java/org/apache/jena/atlas/io/IO.java
----------------------------------------------------------------------
diff --git a/jena-base/src/main/java/org/apache/jena/atlas/io/IO.java b/jena-base/src/main/java/org/apache/jena/atlas/io/IO.java
index 3a74913..18b4df9 100644
--- a/jena-base/src/main/java/org/apache/jena/atlas/io/IO.java
+++ b/jena-base/src/main/java/org/apache/jena/atlas/io/IO.java
@@ -27,8 +27,8 @@ import java.util.zip.GZIPOutputStream ;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
 import org.apache.commons.compress.compressors.snappy.SnappyCompressorInputStream;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.jena.atlas.RuntimeIOException ;
-import org.apache.jena.atlas.lib.FileOps;
 import org.apache.jena.atlas.lib.IRILib ;
 
 public class IO
@@ -81,7 +81,7 @@ public class IO
             filename = IRILib.decode(filename) ;
         }
         InputStream in = new FileInputStream(filename) ;
-        String ext = FileOps.extension(filename);
+        String ext = FilenameUtils.getExtension(filename);
         switch ( ext ) {
             case "":        return in;
             case "gz":      return new GZIPInputStream(in) ;
@@ -91,15 +91,14 @@ public class IO
         return in ;
     }
 
-    private static String[] extensions = { ".gz", ".bz2", ".sz" }; 
+    private static String[] extensions = { "gz", "bz2", "sz" }; 
     
     /** The filename without any compression extension, or the original filename.
      *  It tests for compression types handled by {@link #openFileEx}.
      */
     static public String filenameNoCompression(String filename) {
-        for ( String ext : extensions ) {
-            if ( filename.endsWith(ext) )
-                return filename.substring(0, filename.length()-ext.length());
+        if ( FilenameUtils.isExtension(filename, extensions) ) {
+            return FilenameUtils.removeExtension(filename);
         }
         return filename;
     }
@@ -177,7 +176,7 @@ public class IO
             filename = IRILib.decode(filename) ;
         }
         OutputStream out = new FileOutputStream(filename) ;
-        String ext = FileOps.extension(filename);
+        String ext = FilenameUtils.getExtension(filename);
         switch ( ext ) {
             case "":        return out;
             case "gz":      return new GZIPOutputStream(out) ;


Mime
View raw message