private File getThisDirectory()
            throws FileNotFoundException{
    // Work out the file name of the class file
    Class c = getClass();
    String classFileName = c.getName();
    classFileName = classFileName.substring(classFileName.lastIndexOf(".") + 1);
    classFileName += ".class";
    // Get the path to the class file
    String classFilePath = c.getResource(classFileName).getFile();
    // If the class is in a jar file, then strip this down to the location of the jar file
    String jarFilePath = classFilePath.substring("file:/".length(),
                                                 classFilePath.lastIndexOf("!"));
    File directory = new File(jarFilePath);
    directory = new File(directory.getParent());
    // By default, the file object will store the file name encoded in
    // UTF-8 format, so this needs to be decoded, then returned.
    try{
        directory = new File(new java.net.URLDecoder().decode(directory.getAbsolutePath(),
                            fileEncoding));
        return directory;
    }catch(UnsupportedEncodingException e){
        throw new RuntimeException("File encoding \"" + fileEncoding
                                   + "\" is not supported");
    }
}