JavaUtilspublic class JavaUtils extends Object A collection of different, general-purpose methods for JAVA-specific things |
Fields Summary |
---|
static Logger | log{@link java.util.logging} logging facility |
Constructors Summary |
---|
private JavaUtils()
// we don't allow instantiation
|
Methods Summary |
---|
public static byte[] | getBytesFromFile(java.lang.String fileName)Method getBytesFromFile
byte refBytes[] = null;
{
FileInputStream fisRef = new FileInputStream(fileName);
UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
byte buf[] = new byte[1024];
int len;
while ((len = fisRef.read(buf)) > 0) {
baos.write(buf, 0, len);
}
refBytes = baos.toByteArray();
}
return refBytes;
| public static byte[] | getBytesFromStream(java.io.InputStream inputStream)This method reads all bytes from the given InputStream till EOF and returns
them as a byte array.
byte refBytes[] = null;
{
UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
baos.write(buf, 0, len);
}
refBytes = baos.toByteArray();
}
return refBytes;
| public static void | writeBytesToFilename(java.lang.String filename, byte[] bytes)Method writeBytesToFilename
try {
if (filename != null && bytes != null) {
File f = new File(filename);
FileOutputStream fos = new FileOutputStream(f);
fos.write(bytes);
fos.close();
} else {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "writeBytesToFilename got null byte[] pointed");
}
} catch (Exception ex) {}
|
|