au.csiro.netcdf.util
Class Util

java.lang.Object
  extended by au.csiro.netcdf.util.Util

public class Util
extends Object

Util - utility class with various helpful tools... Copyright 2005, CSIRO Australia All rights reserved.

Version:
$Revision: 78 $ $Date: 2010-07-24 16:23:13 +1000 (Sat, 24 Jul 2010) $
Author:
James Dempsey on 12/10/2005

Constructor Summary
Util()
           
 
Method Summary
static int fastFileLineCounter(String filePath)
          Counts the number of lines in a file.
static boolean fileExists(String filePath)
          Check if a file exists for a given file pathname.
static File getExistingFile(String outputFilenameArg)
          Creates a new File instance from a given pathname string, if the given pathname string exists.
static String getFileExtension(String fileName)
          Method to get the file extension as a String for the supplied file name.
static List<String> getListOfTargetFiles(String foldername, String pattern)
          Retrieve a list of the absolute path names of the files in a folder that match a pattern.
static String[] splitOnNonBackslashedCharacter(String text, String regex)
          Splits the given string around matches of the given non-backslashed regular expression.
static List<String> tokeniseCommaSeparatedString(String commaSeparatedString)
          Splits a comma separated String into a List of tokens.
static boolean validateNumber(String number)
          Check if a string contains a valid number
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

validateNumber

public static boolean validateNumber(String number)
Check if a string contains a valid number

Parameters:
number - The numeric string to be checked
Returns:
True if the number is valid

fileExists

public static boolean fileExists(String filePath)
Check if a file exists for a given file pathname.

Parameters:
filePath - a pathname string.
Returns:
True if the file exists.

fastFileLineCounter

public static int fastFileLineCounter(String filePath)
Counts the number of lines in a file.

Parameters:
filePath - the name of the file to open.
Returns:
The number of lines in the file

getExistingFile

public static File getExistingFile(String outputFilenameArg)
                            throws IllegalArgumentException
Creates a new File instance from a given pathname string, if the given pathname string exists.

Parameters:
outputFilenameArg - a pathname string.
Returns:
a File instance.
Throws:
IllegalArgumentException - thrown if the file can not be found.

getFileExtension

public static String getFileExtension(String fileName)
Method to get the file extension as a String for the supplied file name. If there is no extension it will return null.

Parameters:
fileName - - file name to get extension from
Returns:
String - valid file extension or null.

tokeniseCommaSeparatedString

public static List<String> tokeniseCommaSeparatedString(String commaSeparatedString)
Splits a comma separated String into a List of tokens.

Parameters:
commaSeparatedString - a comma separated String
Returns:
a list of tokens, or an empty list if the String is null or empty.

splitOnNonBackslashedCharacter

public static String[] splitOnNonBackslashedCharacter(String text,
                                                      String regex)
Splits the given string around matches of the given non-backslashed regular expression.

Parameters:
text - the string to be split.
regex - the delimiting regular expression.
Returns:
the array of strings computed by splitting this string around matches of the given non-backslashed regular expression.

getListOfTargetFiles

public static List<String> getListOfTargetFiles(String foldername,
                                                String pattern)
Retrieve a list of the absolute path names of the files in a folder that match a pattern. The pattern uses the characters '?' and '*' to represent a single or multiple wildcard characters. This is the same as often found on Dos/Unix command lines.

Parameters:
foldername - The name of the folder to be searched or the single file if no pattern
pattern - The pattern to be matched against. The wildcard characters '?' and '*' are supported.
Returns:
A list of the absolute names of the matching files


Copyright © 2010. All Rights Reserved.