Package hec.heclib.util
Class HecFileUtil
java.lang.Object
hec.heclib.util.HecFileUtil
Utility methods for file operations, string parsing, and formatting
used within the hec.heclib package. Methods extracted from rma.util.RMAIO
to remove the dependency on rma.util for the heclib sub-project.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetExtension(File f) Returns the lowercase extension of the filename or nullstatic StringgetFileFromPath(String path) Returns the filename portion of a path (after the last separator).static StringParses a line and returns the portion after the delimiter.static StringParses a line and returns the portion after the delimiter.static StringReturns the CWMS_HOME system property.static StringParses a line of the form TYPE<DELIM>PARAM and returns the TYPE portion.static StringBufferleftJustify(int bufsize, String inputStr) Left-justifies a string in a StringBuffer of the given size, padding with spaces on the left.static StringBufferleftJustify(int bufsize, String inputStr, char fill) Left-justifies a string in a StringBuffer of the given size, padding with the fill character on the left.static doubleparseDouble(String str) Parses a string and returns the double value.static doubleparseDouble(String str, double def) Parses a string and returns the double value.static intParses a string and returns the int value.static intParses a string and returns the int value.static StringparsePathEnvVars(String pathName) Given a path with an embedded $APPDATA, returns the path with the $APPDATA or APPDATA env var replaced with the value of the env var.static StringparsePathName(String pathName) Given a path with an embedded $CWMS_HOME, returns the path with the $CWMS_HOME or CWMS_HOME property replaced with the value of the property.static void
-
Field Details
-
separator
- See Also:
-
-
Method Details
-
getType
Parses a line of the form TYPE<DELIM>PARAM and returns the TYPE portion. If the delimiter does not exist, the original line (trimmed) is returned. -
getParam
Parses a line and returns the portion after the delimiter. If the line does not contain the delimiter, an empty string is returned. -
getParam
Parses a line and returns the portion after the delimiter. If the line does not contain the delimiter, an empty string is returned.- Parameters:
line- a String of the form TYPE<DELIM>PARAMdelim- the delimiting substring to search fortrim- whether to trim the result before returning- Returns:
- the portion of line which occurs after delim
-
parseInt
Parses a string and returns the int value. If an exception occurs, the default value is returned. -
parseInt
Parses a string and returns the int value. If an exception occurs, UNDEF_INT is returned. -
parseDouble
Parses a string and returns the double value. If an exception occurs, the default value is returned. -
parseDouble
Parses a string and returns the double value. If an exception occurs, UNDEF_DOUBLE is returned. -
leftJustify
Left-justifies a string in a StringBuffer of the given size, padding with spaces on the left. -
leftJustify
Left-justifies a string in a StringBuffer of the given size, padding with the fill character on the left. -
getSystemHomeDirectory
Returns the CWMS_HOME system property. -
getExtension
Returns the lowercase extension of the filename or null -
getFileFromPath
Returns the filename portion of a path (after the last separator). -
parsePathName
Given a path with an embedded $CWMS_HOME, returns the path with the $CWMS_HOME or CWMS_HOME property replaced with the value of the property. -
parsePathEnvVars
Given a path with an embedded $APPDATA, returns the path with the $APPDATA or APPDATA env var replaced with the value of the env var. -
trimSeparators
-