Need to load image to a byte[] variable.
File file = new File(context.getFilesDir(), body + ".image");
BufferedReader in = new BufferedReader(new FileReader(file));
How can I convert BufferedReader
to byte[]
?
Need to load image to a byte[] variable.
File file = new File(context.getFilesDir(), body + ".image");
BufferedReader in = new BufferedReader(new FileReader(file));
How can I convert BufferedReader
to byte[]
?
A Reader
is meant for converting bytes into characters. That is not what you want here. You need an InputStream
instead. You can then read()
from the stream to your byte[]
array as needed, eg:
File file = new File(context.getFilesDir(), body + ".image");
InputStream in = new BufferedInputStream(new FileInputStream(file));
byte[] buf = new byte[file.length()];
int numRead = in.read(buf);