I have some working code in python that I need to convert to Java.
I read quite a few topics on this forum, but could not find the answer. I am reading a JPG image and converting it to an array of bytes. Then I write this buffer to another file. When I compare the recorded files with both Java and python code, the bytes at the end do not match. Please let me know if you have any suggestion. I need to use an array of bytes to pack the image into a message that needs to be sent to a remote server.
Java code (running on Android)
Reading file:
File queryImg = new File(ImagePath);
int imageLen = (int)queryImg.length();
byte [] imgData = new byte[imageLen];
FileInputStream fis = new FileInputStream(queryImg);
fis.read(imgData);
File record:
FileOutputStream f = new FileOutputStream(new File("/sdcard/output.raw"));
f.write(imgData);
f.flush();
f.close();
Thank!
source
share