commons-file/src/main/java/info/monitorenter/util/FileUtil.java
public static Map.Entry<String, String> cutExtension(final String filename) {
    String prefix;
    String suffix = null;
    final StringTokenizer tokenizer = new StringTokenizer(filename, ".");
    int tokenCount = tokenizer.countTokens();
    if (tokenCount > 1) {
      final StringBuffer prefCollect = new StringBuffer();
      while (tokenCount > 1) {
        tokenCount--;
        prefCollect.append(tokenizer.nextToken());
        if (tokenCount > 1) {
          prefCollect.append(".");
        }
      }
      prefix = prefCollect.toString();
      suffix = tokenizer.nextToken();
    } else {
      prefix = filename;
      suffix = "";
    }
    return new Entry<String, String>(prefix, suffix);
  }
public static Map.Entry<String, String> cutExtension(final String filename) {
    String prefix;
    String suffix = null;
    final StringTokenizer tokenizer = new StringTokenizer(filename, ".");
    int tokenCount = tokenizer.countTokens();
    if (tokenCount > 1) {
      final StringBuffer prefCollect = new StringBuffer();
      while (tokenCount > 1) {
        tokenCount--;
        prefCollect.append(tokenizer.nextToken());
        if (tokenCount > 1) {
          prefCollect.append(".");
        }
      }
      prefix = prefCollect.toString();
      suffix = tokenizer.nextToken();
    } else {
      prefix = filename;
      suffix = "";
    }
    return new Entry<String, String>(prefix, suffix);
  }
public static Map . Entry < String , String > cutExtension ( final String filename ) { String prefix ; String suffix = null ; final StringTokenizer tokenizer = new StringTokenizer ( filename , "." ) ; int tokenCount = tokenizer . countTokens ( ) ; if ( tokenCount > 1 ) { final StringBuffer prefCollect = new StringBuffer ( ) ; while ( tokenCount > 1 ) { tokenCount -- ; prefCollect . append ( tokenizer . nextToken ( ) ) ; if ( tokenCount > 1 ) { prefCollect . append ( "." ) ; } } prefix = prefCollect . toString ( ) ; suffix = tokenizer . nextToken ( ) ; } else { prefix = filename ; suffix = "" ; } return new Entry < String , String > ( prefix , suffix ) ; }
Cuts a String into the part before the last dot and after the last dot. If
only one dot is contained on the first position, it will completely be used
as prefix part.
<p>

<pre>
Map.Entry entry = FileUtil.getPotentialExtension(&quot;A.Very.Strange.Name.txt&quot;);
String prefix = (String) entry.getKey(); // prefix is &quot;A.Very.Strange.Name&quot;.
String suffix = (String) entry.getValue(); // suffix is &quot;txt&quot;;

entry = FileUtil.getPotentialExtension(&quot;.profile&quot;);
String prefix = (String) entry.getKey(); // prefix is &quot;.profile&quot;.
String suffix = (String) entry.getValue(); // suffix is &quot;&quot;;

entry = FileUtil.getPotentialExtension(&quot;bash&quot;);
String prefix = (String) entry.getKey(); // prefix is &quot;bash&quot;.
String suffix = (String) entry.getValue(); // suffix is &quot;&quot;;

</pre>

<p>


@param filename
A String that is interpreted to be a file name: The last dot ('.')
is interpreted to be the extension delimiter.

@return A <tt> java.util.Map.Entry</tt> instance containing a String for
the filename at the key side and a String for the extension at the
value side.
Cuts a String into the part before the last dot and after the last dot . If only one dot is contained on the first position it will completely be used as prefix part . <p >