Charles Bell
Posts: 519
Nickname: charles
Registered: Feb, 2002
|
|
Re: reading binary files
|
Posted: Jun 17, 2002 12:34 AM
|
|
create a FileInputStream with the file you want to read as its argument: File dataFile = new File("data.pat"); FileInputStream fis = new FileInputStream(dataFile); DataInputStream dis = new DataInputStream(file);
//then its just a matter of reading in the 256x256 //pixel data bytes in some kind of loop. int framepixels = 256*256; for (int frame = 0;frame<10;frame++){ for (int i = 0;i<framepixels;i++){ byte firstPixelByte = dis.readByte(); byte secondPixelByte = dis.readByte(); //add your code to process the bytes here } }
//Its your program, finish it.
256x256 pixels corresponds to one frame loop 10 times for ten frames
|
|