Вы можете преобразовать ваше изображение в байтовый массив следующим образом.
BufferedImage bImage = ImageIO.read(new File("sample.jpg"));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(bImage, "jpg", bos );
byte [] data = bos.toByteArray();
Да, вы можете напрямую сравнить 2 byteArray.
Просто сделайте что-то вроде
if (bytearray1.length == bytearray2.length)
//its same
Попробуйте это записать ByteArray в текстовый файл
public void writeToFile(byte[] array)
{
try
{
String path = "/data/data/YOURFILE.txt"; //provide your path here
File file = new File(path);
if (!file.exists()) { //just to check if file is actually present
file.createNewFile();
}
FileOutputStream stream = new FileOutputStream(path);
stream.write(array);
} catch (FileNotFoundException e1)
{
e1.printStackTrace();
}
}