1 package com.instantbank.common.uiutils;
2
3 import java.io.ByteArrayOutputStream;
4 import java.io.IOException;
5 import java.io.FileInputStream;
6 import java.io.File;
7
8
14 public class ByteArrayFromFile {
15
16
19 static final int BUFSIZE = 512;
20
21
24 private byte[] buff = new byte[BUFSIZE];
25
26
29 private ByteArrayOutputStream outbyte = new ByteArrayOutputStream();
30
31
32
38 public ByteArrayFromFile(String file) throws IOException {
39 this(new File(file));
40 }
41
42
43
49
50 public ByteArrayFromFile(File file) throws IOException {
51 FileInputStream in = new FileInputStream(file);
52 for(int readSize = in.read(buff); readSize >= 0; readSize = in.read(buff)) {
53 outbyte.write(buff, 0, readSize);
54 }
55 in.close();
56 }
57
58
59
64 public byte[] getBytes() {
65 return outbyte.toByteArray();
66 }
67 }
68
69