Package com.openstego.desktop.util
Class CommonUtil
- java.lang.Object
-
- com.openstego.desktop.util.CommonUtil
-
public class CommonUtil extends Object
Common utilities for OpenStego
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
byteToInt(int b)
Byte to Int converterstatic int
ceilingHalf(int num)
Returns the ceiling of the half of the input valuestatic byte[]
fileToBytes(File file)
Method to get byte array data from given filestatic int
floorHalf(int num)
Returns the floor of the half of the input valuestatic int
mod(int num, int div)
Returns the modulus of the input value (taking care of the sign of the value)static List<File>
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 byte[]
streamToBytes(InputStream is)
Method to get byte array data from given InputStreamstatic void
writeFile(byte[] fileData, File file)
Method to write file data to diskstatic void
writeFile(byte[] fileData, String fileName)
Method to write file data to disk
-
-
-
Method Detail
-
streamToBytes
public static byte[] streamToBytes(InputStream is) throws OpenStegoException
Method to get byte array data from given InputStream- Parameters:
is
- InputStream to read- Returns:
- Stream data as byte array
- Throws:
OpenStegoException
- Processing issues
-
fileToBytes
public static byte[] fileToBytes(File file) throws OpenStegoException
Method to get byte array data from given file- Parameters:
file
- File to read- Returns:
- File data as byte array
- Throws:
OpenStegoException
- Processing issues
-
writeFile
public static void writeFile(byte[] fileData, String fileName) throws OpenStegoException
Method to write file data to disk- Parameters:
fileData
- File datafileName
- File name (If this isnull
, then data is written to stdout)- Throws:
OpenStegoException
- Processing issues
-
writeFile
public static void writeFile(byte[] fileData, File file) throws OpenStegoException
Method to write file data to disk- Parameters:
fileData
- File datafile
- File object (If this isnull
, then data is written to stdout)- Throws:
OpenStegoException
- Processing issues
-
setEnabled
public static void setEnabled(JTextField textField, boolean enabled)
Method to enable/disable a Swing JTextField object- Parameters:
textField
- Swing JTextField objectenabled
- Flag to indicate whether to enable or disable the object
-
parseFileList
public static List<File> parseFileList(String fileList, String delimiter)
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
-
-