Skip to content

Instantly share code, notes, and snippets.

@t3rmian
Created August 3, 2020 11:45
Show Gist options
  • Save t3rmian/3ddb7e1a93555657ba78a9f7fdbff2b8 to your computer and use it in GitHub Desktop.
Save t3rmian/3ddb7e1a93555657ba78a9f7fdbff2b8 to your computer and use it in GitHub Desktop.
Reverse binary file
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
class Scratch {
public static void main(String[] args) throws IOException {
RandomAccessFile file = new RandomAccessFile(new File(args[0]), "r");
File out = new File(args[0] + ".rev");
FileOutputStream outFile = new FileOutputStream(out);
long index, length;
length = file.length() - 1;
for (index = length; index >= 0; index--) {
file.seek(index);
int s = file.read();
outFile.write(s);
}
file.close();
outFile.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment