Package bdsup2sub.utils
Class ToolBox
java.lang.Object
bdsup2sub.utils.ToolBox
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDouble(double value) static doubleConvert String to doublestatic byte[]Returns the first few bytes of a file to check it's typestatic StringgetFilename(String path, String filename, List<String> extensions, boolean loadDialog, Component parent) Get file name via "file chooser" dialogstatic intConvert String to integerstatic StringleftZeroPad(int value, int width) static voidWrite ASCII string to buffer[index] (no special handling for multi-byte characters)static voidShow a dialog with details about an exceptionstatic StringtoHexLeftZeroPadded(long value, int width)
-
Field Details
-
FPS_FORMATTER
-
-
Constructor Details
-
ToolBox
public ToolBox()
-
-
Method Details
-
leftZeroPad
-
toHexLeftZeroPadded
-
formatDouble
-
setString
Write ASCII string to buffer[index] (no special handling for multi-byte characters)- Parameters:
buffer- Byte arrayindex- Index to write tos- String containing ASCII characters- Throws:
ArrayIndexOutOfBoundsException
-
showException
Show a dialog with details about an exception- Parameters:
ex- Throwable/Exception to display
-
getFilename
public static String getFilename(String path, String filename, List<String> extensions, boolean loadDialog, Component parent) Get file name via "file chooser" dialog- Parameters:
path- Default path (without file name).filename- Default file name (without path).extensions- Array of allowed extensions (without ".")loadDialog- If true, this is a load dialog, else it's a save dialogparent- Parent component (Frame, Window)- Returns:
- Selected filename or null if canceled
-
getFileID
Returns the first few bytes of a file to check it's type- Parameters:
fname- Filename of the filenum- Number of bytes to return- Returns:
- Array of bytes (size num) from the beginning of the file
-
getInt
Convert String to integer- Parameters:
s- String containing integer (assumed: positive)- Returns:
- Integer value or -1.0 if no valid numerical value
-
getDouble
Convert String to double- Parameters:
s- String containing double- Returns:
- Double value or -1.0 if no valid numerical value
-