java - Convert file to byte array in reverse order -
byte[] bfile = new byte[(int) file.length()]; fileinputstream fileinputstream = new fileinputstream(file); fileinputstream.read(bfile); fileinputstream.close();
this code let's me convert file byte array, looking reading file end start (in reverse order)
edit : dont wan't read entire file. part @ end (example around 1000 bytes)
file file = new file(/*file path*/); byte[] bfile = new byte[1000]; randomaccessfile fileinputstream = new randomaccessfile(file, "r"); fileinputstream.seek(fileinputstream.length() - bfile[0].length); fileinputstream.read(bfile, 0, bfile.length); fileinputstream.close();
i figured out, reading last 1000 bytes of file