1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| FileInputStream in;
byte[] bytes = null;
try {
in = new FileInputStream(Environment.getExternalStorageDirectory().getPath() + "/out.jpg");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int bytesRead;
bytesRead = in.read(b);
while (bytesRead != -1) {
bos.write(b, 0, bytesRead);
}
bytes = bos.toByteArray();
} catch (FileNotFoundException e) {
e.printStackTrace();
bytes = null;
} catch (IOException e) {
e.printStackTrace();
bytes = null;
}
if (bytes != null) {
upload.buff = new String(bytes);
} |
Partager