Package com.openstego.desktop.util
Class CommonUtil
java.lang.Object
com.openstego.desktop.util.CommonUtil
Common utilities for OpenStego
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
byteToInt
(int b) Byte to Int converterstatic int
ceilingHalf
(int num) Returns the ceiling of the half of the input valuestatic int
floorHalf
(int num) Returns the floor of the half of the input valuestatic byte[]
getFileBytes
(File file) Method to get byte array data from given filestatic byte[]
Method to get byte array data from given InputStreamstatic double
max
(double x, double y) Get maximum of two given valuesstatic int
max
(int x, int y) Get maximum of two given valuesstatic double
min
(double x, double y) Get minimum of two given valuesstatic int
min
(int x, int y) Get minimum of two given valuesstatic int
mod
(int num, int div) Returns the modulus of the input value (taking care of the sign of the value)parseFileList
(String fileList, String delimiter) Method to parse a delimiter separated list of files into arraylist of filenames.static void
setEnabled
(JTextField textField, boolean enabled) Method to enable/disable a Swing JTextField objectstatic void
Method to write file data to diskstatic void
Method to write file data to disk
-
Method Details
-
getStreamBytes
Method to get byte array data from given InputStream- Parameters:
is
- InputStream to read- Returns:
- Stream data as byte array
- Throws:
OpenStegoException
-
getFileBytes
Method to get byte array data from given file- Parameters:
file
- File to read- Returns:
- File data as byte array
- Throws:
OpenStegoException
-
writeFile
Method to write file data to disk- Parameters:
fileData
- File datafileName
- File name (If this isnull
, then data is written to stdout)- Throws:
OpenStegoException
-
writeFile
Method to write file data to disk- Parameters:
fileData
- File datafile
- File object (If this isnull
, then data is written to stdout)- Throws:
OpenStegoException
-
setEnabled
Method to enable/disable a Swing JTextField object- Parameters:
textField
- Swing JTextField objectenabled
- Flag to indicate whether to enable or disable the object
-
parseFileList
Method to parse a delimiter separated list of files into arraylist of filenames. It supports wildcard characters "*" and "?" within the filenames.- Parameters:
fileList
- Delimiter separated list of filenamesdelimiter
- Delimiter for tokenization- Returns:
- List of filenames after tokenizing and wildcard expansion
-
byteToInt
public static int byteToInt(int b) Byte to Int converter- Parameters:
b
- Input byte value- Returns:
- Int value
-
floorHalf
public static int floorHalf(int num) Returns the floor of the half of the input value- Parameters:
num
- Input number- Returns:
- Floor of the half of the input number
-
ceilingHalf
public static int ceilingHalf(int num) Returns the ceiling of the half of the input value- Parameters:
num
- Input number- Returns:
- Ceiling of the half of the input number
-
mod
public static int mod(int num, int div) Returns the modulus of the input value (taking care of the sign of the value)- Parameters:
num
- Input numberdiv
- Divisor for modulus- Returns:
- Modulus of num by div
-
max
public static int max(int x, int y) Get maximum of two given values- Parameters:
x
- Value 1y
- value 2- Returns:
- Max of the two values
-
max
public static double max(double x, double y) Get maximum of two given values- Parameters:
x
- Value 1y
- value 2- Returns:
- Max of the two values
-
min
public static int min(int x, int y) Get minimum of two given values- Parameters:
x
- Value 1y
- value 2- Returns:
- Min of the two values
-
min
public static double min(double x, double y) Get minimum of two given values- Parameters:
x
- Value 1y
- value 2- Returns:
- Min of the two values
-