← Back to team overview

kadosu-dev team mailing list archive

[Branch ~kadosu-dev/kadosu/main] Rev 105: o add util method for getting the java version

 

------------------------------------------------------------
revno: 105
committer: Martin Schaaf <mascha@xxxxxxxxxx>
branch nick: kadosu
timestamp: Sun 2009-11-08 21:42:57 +0100
message:
  o add util method for getting the java version
modified:
  org.kadosu/src/main/java/org/kadosu/misc/Utils.java


--
lp:kadosu
https://code.launchpad.net/~kadosu-dev/kadosu/main

Your team Kadosu Developer is subscribed to branch lp:kadosu.
To unsubscribe from this branch go to https://code.launchpad.net/~kadosu-dev/kadosu/main/+edit-subscription.
=== modified file 'org.kadosu/src/main/java/org/kadosu/misc/Utils.java'
--- org.kadosu/src/main/java/org/kadosu/misc/Utils.java	2009-03-23 12:48:29 +0000
+++ org.kadosu/src/main/java/org/kadosu/misc/Utils.java	2009-11-08 20:42:57 +0000
@@ -13,6 +13,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Random;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.FSDirectory;
@@ -23,6 +25,23 @@
  */
 public class Utils {
 
+  public static String[] JAVA_VERSION;
+
+  static {
+    Pattern compile = Pattern.compile( "([0-9]*?)\\.([0-9]*?)\\.([0-9]*?)-(.*)");
+    final String javaVersion = System.getProperty( "java.version");
+    Matcher matcher = compile.matcher( javaVersion);
+    if (matcher.matches()) {
+      Utils.JAVA_VERSION = new String[] {
+          matcher.group( 1), matcher.group( 2), matcher.group( 3), matcher.group( 4)
+      };
+    } else {
+      Utils.JAVA_VERSION = new String[] {
+          "1", "6", "0", ""
+      };
+    }
+  }
+
   /**
    * @param first
    * @param last
@@ -68,7 +87,7 @@
         final long randL = random.nextLong();
         final String randS = String.valueOf( randL);
 
-        dir = new File( concatePaths( whereLocal, randS));
+        dir = new File( Utils.concatePaths( whereLocal, randS));
         if (!dir.exists()) {
           if (dir.mkdir()) {
             dir.deleteOnExit();
@@ -147,11 +166,11 @@
     return result;
   }
 
-  public static void deleteDirectory( File tempPath) {
+  public static void deleteDirectory( final File tempPath) {
     if (tempPath.isDirectory()) {
       File[] files = tempPath.listFiles();
       for (File file : files) {
-        deleteDirectory( file);
+        Utils.deleteDirectory( file);
       }
     }
     tempPath.delete();