DN10
This commit is contained in:
parent
84a6f51bd1
commit
75eb6fa962
38
src/DN10.java
Normal file
38
src/DN10.java
Normal file
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
BIN
viri/lion.png
Normal file
BIN
viri/lion.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
Loading…
Reference in New Issue
Block a user