Android : android convert file of size > 1gb to byte array

on Thursday, September 11, 2014


I want convert the data to byte array. so that, i can send it over the network. For small file it is working. but for file of size>900 mb, am getting runtime exception. Here is my code.



try {
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int len = 0;
while ((len = is.read(buffer)) != -1) {
byteBuffer.write(buffer, 0, len);
}
is.close();
return byteBuffer;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

0 comments:

Post a Comment