Skip to content

Instantly share code, notes, and snippets.

@horitaku1124
Created May 6, 2020 07:13
Show Gist options
  • Save horitaku1124/c6442a7310dacbc77f1dbc043c2902fd to your computer and use it in GitHub Desktop.
Save horitaku1124/c6442a7310dacbc77f1dbc043c2902fd to your computer and use it in GitHub Desktop.
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* http://www.file-recovery.com/mp4-signature-format.htm
*/
public class IsoFileReader {
public static void main(String[] args) throws IOException {
File file = new File("test1.mp4");
try(RandomAccessFile reader = new RandomAccessFile(file, "r")) {
int position = reader.readInt();
System.out.println(position);
{
byte[] mark = new byte[8];
int len = reader.read(mark);
String str = new String(mark, 0, len);
System.out.println(str);
}
reader.skipBytes(4);
{
byte[] mark = new byte[8];
int len = reader.read(mark);
String str = new String(mark, 0, len);
System.out.println(str);
}
reader.seek(0);
reader.skipBytes(position);
System.out.println(reader.readInt());
{
byte[] mark = new byte[4];
int len = reader.read(mark);
String str = new String(mark, 0, len);
System.out.println(str);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment