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


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo