diff --git a/src/DN10.java b/src/DN10.java new file mode 100644 index 0000000..740e544 --- /dev/null +++ b/src/DN10.java @@ -0,0 +1,38 @@ +import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.IOException; + +class Chunk { + int length; + String type; + byte[] data; + + Chunk(int length, String type, byte[] data) { + this.length = length; + this.type = type; + this.data = data; + } + + static Chunk read(DataInputStream dis) throws IOException { + int length = dis.readInt(); + String type = new String(dis.readNBytes(4)); + byte[] data = dis.readNBytes(length); + dis.skipBytes(4); + return new Chunk(length, type, data); + } +} + +public class DN10 { + public static void main(String[] args) throws IOException { + FileInputStream fis = new FileInputStream(args[0]); + DataInputStream dis = new DataInputStream(fis); + + dis.skipBytes(8); // header + + Chunk chunk; + do { + chunk = Chunk.read(dis); + System.out.printf("Chunk: %s, length: %d\n", chunk.type, chunk.length); + } while (!chunk.type.equals("IEND")); + } +} diff --git a/viri/lion.png b/viri/lion.png new file mode 100644 index 0000000..2998ed0 Binary files /dev/null and b/viri/lion.png differ