Index: trunk/java-utils/src/main/java/de/ugoe/cs/util/FileTools.java
===================================================================
--- trunk/java-utils/src/main/java/de/ugoe/cs/util/FileTools.java	(revision 1241)
+++ trunk/java-utils/src/main/java/de/ugoe/cs/util/FileTools.java	(revision 1243)
@@ -99,4 +99,49 @@
         return (new String(buffer)).split(splitString);
     }
+    
+    /**
+     * <p>
+     * Autocompletes a give path. The path must be absolute. Otherwise, autocompletion
+     * is not possible.
+     * </p>
+     * 
+     * @param prefix
+     *            the prefix to be complete
+     * @return the auto completed path
+     */
+    public static String autoCompletePath(String prefix) {
+        File prefixFile = new File(prefix);
+        File parentDir = prefixFile.getParentFile();
+        
+        if (parentDir == null) {
+            // the prefix does not denote a path or denotes one of the root directories.
+            // this can not be auto completed
+            return prefix;
+        }
+        
+        String[] completions = null;
+        
+        if (parentDir.exists()) {
+            completions = parentDir.list();
+        }
+        
+        if (completions == null) {
+            completions = new String[0];
+        }
+        
+        String completedPrefix;
+        
+        completedPrefix = StringTools.autocomplete(prefixFile.getName(), completions);
+        
+        File completedFile = new File(parentDir, completedPrefix);
+        
+        if (completedFile.exists() && completedFile.isDirectory()) {
+            return completedFile.getAbsolutePath() + File.separator;
+        }
+        else {
+            return (parentDir.getAbsolutePath() + File.separator + completedPrefix)
+                .replaceAll("//", "/");
+        }
+    }
 
 }
Index: trunk/java-utils/src/main/java/de/ugoe/cs/util/StringTools.java
===================================================================
--- trunk/java-utils/src/main/java/de/ugoe/cs/util/StringTools.java	(revision 1241)
+++ trunk/java-utils/src/main/java/de/ugoe/cs/util/StringTools.java	(revision 1243)
@@ -14,4 +14,7 @@
 
 package de.ugoe.cs.util;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
@@ -63,3 +66,58 @@
         return result;
     }
+    
+    /**
+     * <p>
+     * Performs an auto completion of the provided prefix using the given potential completions.
+     * The method searches for all completions that start with the given prefix and stores them in
+     * a subset. It then extends the prefix with characters of the subset of completions as long as
+     * the prefix still prefixes all completions in the subset. The result is then returned. If
+     * there is no matching completion or if there are several matching completions differing
+     * in the succeeding letter, the prefix is returned as is. If there is only one matching
+     * completion this completion is returned.
+     * </p>
+     * 
+     * @param prefix      the prefix to be further completed
+     * @param completions the potential completions of the prefix
+     * 
+     * @return as described
+     */
+    public static String autocomplete(String prefix, String[] completions) {
+        List<String> matchingCompletions = new ArrayList<String>();
+        for (String completion : completions) {
+            if (completion.startsWith(prefix)) {
+                matchingCompletions.add(completion);
+            }
+        }
+        
+        StringBuffer completedPrefix = new StringBuffer(prefix);
+        
+        boolean foundCompletion = false;
+        
+        while (!foundCompletion) {
+            char nextCompletionChar = 0;
+            for (String completion : matchingCompletions) {
+                if (completion.length() > completedPrefix.length()) {
+                    if (nextCompletionChar == 0) {
+                        nextCompletionChar = completion.charAt(completedPrefix.length());
+                    }
+                    else if (nextCompletionChar != completion.charAt(completedPrefix.length())) {
+                        foundCompletion = true;
+                    }
+                }
+                else {
+                    foundCompletion = true;
+                }
+            }
+            
+            if (!foundCompletion && (nextCompletionChar != 0)) {
+                completedPrefix.append(nextCompletionChar);
+            }
+            else {
+                foundCompletion = true;
+            }
+        }
+        
+        return completedPrefix.toString();
+    }
 }
Index: trunk/java-utils/src/main/java/de/ugoe/cs/util/console/CommandExecuter.java
===================================================================
--- trunk/java-utils/src/main/java/de/ugoe/cs/util/console/CommandExecuter.java	(revision 1241)
+++ trunk/java-utils/src/main/java/de/ugoe/cs/util/console/CommandExecuter.java	(revision 1243)
@@ -30,4 +30,6 @@
 import java.util.jar.JarInputStream;
 import java.util.logging.Level;
+
+import de.ugoe.cs.util.StringTools;
 
 /**
@@ -356,42 +358,11 @@
         Command[] commands = getAvailableCommands();
         
-        List<Command> matchingCommands = new ArrayList<Command>();
-        for (Command command : commands) {
-            String commandName = command.getClass().getSimpleName().substring(3);
-            if (commandName.startsWith(commandPrefix)) {
-                matchingCommands.add(command);
-            }
-        }
+        String[] completions = new String[commands.length];
         
-        StringBuffer completedPrefix = new StringBuffer(commandPrefix);
+        for (int i = 0; i < commands.length; i++) {
+            completions[i] = commands[i].getClass().getSimpleName().substring(3);
+        }
         
-        boolean foundCompletion = false;
-        
-        while (!foundCompletion) {
-            char nextCompletionChar = 0;
-            for (Command command : matchingCommands) {
-                String commandName = command.getClass().getSimpleName().substring(3);
-                if (commandName.length() > completedPrefix.length()) {
-                    if (nextCompletionChar == 0) {
-                        nextCompletionChar = commandName.charAt(completedPrefix.length());
-                    }
-                    else if (nextCompletionChar != commandName.charAt(completedPrefix.length())) {
-                        foundCompletion = true;
-                    }
-                }
-                else {
-                    foundCompletion = true;
-                }
-            }
-            
-            if (!foundCompletion && (nextCompletionChar != 0)) {
-                completedPrefix.append(nextCompletionChar);
-            }
-            else {
-                foundCompletion = true;
-            }
-        }
-        
-        return completedPrefix.toString();
+        return StringTools.autocomplete(commandPrefix, completions);
     }
 }
