0

In my android application i am recording and saving the file in sdcard. Now i would like to convert this saved file to byte array and sent it to the server.

Could anyone please let me know as how can i convert video files to byte array

Please forward your valuable suggestions.

Thanks in advance :)

Remmyabhavan
  • 1,689
  • 5
  • 36
  • 65
  • Not knowing Android at all other than as a user, but a recorded video file is just a file... why the byte array? – Marc B Feb 12 '11 at 19:57
  • This seems more like what you were looking for way back when: [how-to-convert-files-to-byte-array-to-send-via-bluetooth-socket-in-android][1] [1]: http://stackoverflow.com/questions/8614641/how-to-convert-files-to-byte-array-to-send-via-bluetooth-socket-in-android – zwebie Aug 26 '12 at 08:59

1 Answers1

1

try this:

String strFile=null;
File file=new File(pathOnSdCard);
try {
byte[] data = FileUtils.readFileToByteArray(file);//Convert any file, image or video into byte array
strFile = Base64.encodeToString(data, Base64.NO_WRAP);//Convert byte array into string
} catch (IOException e) {
e.printStackTrace();
}
return strFile;
}
Ahmad Arslan
  • 4,498
  • 8
  • 38
  • 59