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 SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static intbyteToInt(int b)Byte to Int converterstatic intceilingHalf(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 intfloorHalf(int num)Returns the floor of the half of the input valuestatic intmod(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 voidsetEnabled(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 voidwriteFile(byte[] fileData, File file)Method to write file data to diskstatic voidwriteFile(byte[] fileData, String fileName)Method to write file data to disk
 
- 
- 
- 
Method Detail- 
streamToBytespublic 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
 
 - 
fileToBytespublic 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
 
 - 
writeFilepublic static void writeFile(byte[] fileData, String fileName) throws OpenStegoExceptionMethod to write file data to disk- Parameters:
- fileData- File data
- fileName- File name (If this is- null, then data is written to stdout)
- Throws:
- OpenStegoException- Processing issues
 
 - 
writeFilepublic static void writeFile(byte[] fileData, File file) throws OpenStegoExceptionMethod to write file data to disk- Parameters:
- fileData- File data
- file- File object (If this is- null, then data is written to stdout)
- Throws:
- OpenStegoException- Processing issues
 
 - 
setEnabledpublic static void setEnabled(JTextField textField, boolean enabled) Method to enable/disable a Swing JTextField object- Parameters:
- textField- Swing JTextField object
- enabled- Flag to indicate whether to enable or disable the object
 
 - 
parseFileListpublic 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 filenames
- delimiter- Delimiter for tokenization
- Returns:
- List of filenames after tokenizing and wildcard expansion
 
 - 
byteToIntpublic static int byteToInt(int b) Byte to Int converter- Parameters:
- b- Input byte value
- Returns:
- Int value
 
 - 
floorHalfpublic 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
 
 - 
ceilingHalfpublic 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
 
 - 
modpublic 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 number
- div- Divisor for modulus
- Returns:
- Modulus of num by div
 
 
- 
 
-