Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javafe.filespace
Class Extension

    java.lang.Object
      javafe.filespace.Extension

public class Extension
extends java.lang.Object

This module contains functions for decomposing filenames (Strings) into a basename and an extension. I.e., "foo.java" -> "foo", ".java" and "bar" -> "bar", "".

Extensions include the '.' if present so that no extension can be distinguished from a blank one (i.e., "foo.").

This also has the property that concatenating a filename's basename with its extension always gives the original filename.

Constructor Summary
`Extension()`

Method Summary
`static java.lang.String` | `getBasename(java.lang.String filename)` Return the basename of a filename -- the part of a filename that preceeds its extension (if any).
`static java.lang.String` | `getExtension(java.lang.String filename)` Return the extension of a filename (including the ".") or "" if it has none.
`static boolean` | `hasExtension(java.lang.String filename, java.lang.String extension)` Return true iff a given filename has a particular extension.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Extension

    public Extension()

Method Detail

### getExtension

    public static java.lang.String getExtension(java.lang.String filename)

  Return the extension of a filename (including the ".") or "" if it has none. The extension is defined as the substring starting with the last "." and ending at the end of the filename.

### getBasename

    public static java.lang.String getBasename(java.lang.String filename)

  Return the basename of a filename -- the part of a filename that preceeds its extension (if any). More precisely, the prefix of the filename preceeding the last "." or the entire filename if no "." is present.

### hasExtension

    public static boolean hasExtension(java.lang.String filename,
                                       java.lang.String extension)

  Return true iff a given filename has a particular extension.

  It is faster to use endsWith for non-empty extensions; use this function when extension may be empty ("").

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage