Created
August 3, 2020 11:45
-
-
Save t3rmian/3ddb7e1a93555657ba78a9f7fdbff2b8 to your computer and use it in GitHub Desktop.
Reverse binary file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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