fr.umlv.unitex
Class Util

java.lang.Object
  extended by fr.umlv.unitex.Util

public class Util
extends java.lang.Object

This class provides methods to get information about files, like path, file name or extension.

Author:
Sébastien Paumier

Constructor Summary
Util()
           
 
Method Summary
static java.lang.String getExtensionInLowerCase(java.io.File f)
          Returns the extension in lower case of a file
static java.lang.String getExtensionInLowerCase(java.lang.String s)
          Returns the extension in lower case of a file
static java.lang.String getFileNameExtension(java.io.File f)
          Returns the extension of a file.
static java.lang.String getFileNameExtension(java.lang.String s)
          Returns the extension of a file.
static java.lang.String getFileNameWithoutExtension(java.io.File f)
          Returns the name without extension of a file.
static java.lang.String getFileNameWithoutExtension(java.lang.String s)
          Returns the name without extension of a file.
static java.lang.String getFileNameWithoutFilePath(java.io.File f)
          Returns the file name of a file, without the path.
static java.lang.String getFileNameWithoutFilePath(java.lang.String s)
          Returns the file name of a file, without the path.
static java.lang.String getFilePathWithoutFileName(java.io.File f)
          Returns the path name of a file, without the file name.
static java.lang.String getFilePathWithoutFileName(java.lang.String s)
          Returns the path name of a file, without the file name.
static java.lang.String getHtmlPageTitle(java.io.File file)
          Takes a file and looks for the text between the tags <title> and </title>.
static int toInt(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

getFileNameWithoutExtension

public static java.lang.String getFileNameWithoutExtension(java.lang.String s)
Returns the name without extension of a file.

Parameters:
s - the file name
Returns:
the name without extension

getFileNameWithoutExtension

public static java.lang.String getFileNameWithoutExtension(java.io.File f)
Returns the name without extension of a file.

Parameters:
f - the file name
Returns:
the name without extension

getFileNameExtension

public static java.lang.String getFileNameExtension(java.lang.String s)
Returns the extension of a file.

Parameters:
s - the file name
Returns:
the extension if there is one, the empty string otherwise

getFileNameExtension

public static java.lang.String getFileNameExtension(java.io.File f)
Returns the extension of a file. This method is equivalent to a call to Util.getFileNameExtension(f.getName()).

Parameters:
f - the file
Returns:
the extension if there is one, the empty string otherwise

getFilePathWithoutFileName

public static java.lang.String getFilePathWithoutFileName(java.lang.String s)
Returns the path name of a file, without the file name.

Parameters:
s - the file name
Returns:
the path

getFilePathWithoutFileName

public static java.lang.String getFilePathWithoutFileName(java.io.File f)
Returns the path name of a file, without the file name. This method is equivalent to a call to getFilePathWithoutFileName(f.getName()).

Parameters:
f - the file
Returns:
the path

getFileNameWithoutFilePath

public static java.lang.String getFileNameWithoutFilePath(java.io.File f)
Returns the file name of a file, without the path.

Parameters:
f - the file
Returns:
the file name, without the path

getFileNameWithoutFilePath

public static java.lang.String getFileNameWithoutFilePath(java.lang.String s)
Returns the file name of a file, without the path. This method is equivalent to a call to getFileNameWithoutFilePath(new File(s)).

Parameters:
s - the file name
Returns:
the file name, without the path

getExtensionInLowerCase

public static java.lang.String getExtensionInLowerCase(java.lang.String s)
Returns the extension in lower case of a file

Parameters:
s - file name
Returns:
the extension

getExtensionInLowerCase

public static java.lang.String getExtensionInLowerCase(java.io.File f)
Returns the extension in lower case of a file

Parameters:
f - the file
Returns:
the extension

toInt

public static int toInt(java.lang.String s)

getHtmlPageTitle

public static java.lang.String getHtmlPageTitle(java.io.File file)
Takes a file and looks for the text between the tags <title> and </title>. WARNING: the result string is taken rawly and might be wrongly encoded if the title is not in ASCII.

Parameters:
file - the HTML file
Returns:
the title of the page; null if the pattern is not found in the first 200 bytes of the file