M
MattC
I have a file that I need to read into my program and convert to a byte
array (byte [] ). The code below works but it seems sort of "smelly".
Can someone suggest a cleaner, more eloquent, way of accomplishing
this?
Thanks!
****************
/* Move the data in the File object to a byte array */
InputStream in = new FileInputStream(templateFile);
int length = new Long(templateFile.length()).intValue();
ByteArrayOutputStream out = new ByteArrayOutputStream(length);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
byte[] certBytes = new byte[out.size()];
certBytes = out.toByteArray();
array (byte [] ). The code below works but it seems sort of "smelly".
Can someone suggest a cleaner, more eloquent, way of accomplishing
this?
Thanks!
****************
/* Move the data in the File object to a byte array */
InputStream in = new FileInputStream(templateFile);
int length = new Long(templateFile.length()).intValue();
ByteArrayOutputStream out = new ByteArrayOutputStream(length);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
byte[] certBytes = new byte[out.size()];
certBytes = out.toByteArray();