protected void readFile(Object raster,File file,LayerType layerType) throws IOException {
  if (!doIt) {
    return;
  }
  InputStream iStream=new FileInputStream(file);
  ByteBuffer bbuf=null;
  byte[] bbArray=null;
switch (layerType) {
case none:
case footprint:
case viewshed:
case derivative:
    break;
case elevation:
case field:
  float[][] fArray=(float[][])raster;
bbArray=new byte[fArray[0].length * 4];
bbuf=ByteBuffer.wrap(bbArray);
FloatBuffer fbuf=bbuf.asFloatBuffer();
for (int i=0; i < fArray.length; ++i) {
iStream.read(bbArray);
bbuf.rewind();
fbuf.get(fArray[i]);
fbuf.rewind();
}
break;
case colorimage:
int[][] iArray=(int[][])raster;
bbArray=new byte[iArray[0].length * 4];
bbuf=ByteBuffer.wrap(bbArray);
IntBuffer ibuf=bbuf.asIntBuffer();
for (int i=0; i < iArray.length; ++i) {
iStream.read(bbArray);
bbuf.rewind();
ibuf.get(iArray[i]);
ibuf.rewind();
}
break;
case grayimage:
byte[][] bArray=(byte[][])raster;
for (int i=0; i < bArray.length; ++i) {
iStream.read(bArray[i]);
}
break;
}
iStream.close();
}

protected void readFile ( Object raster , File file , LayerType layerType ) throws IOException { if ( ! doIt ) { return ; } InputStream iStream = new FileInputStream ( file ) ; ByteBuffer bbuf = null ; byte [ ] bbArray = null ; switch ( layerType ) { case none : case footprint : case viewshed : case derivative : break ; case elevation : case field : float [ ] [ ] fArray = ( float [ ] [ ] ) raster ; bbArray = new byte [ fArray [ 0 ] . length * 4 ] ; bbuf = ByteBuffer . wrap ( bbArray ) ; FloatBuffer fbuf = bbuf . asFloatBuffer ( ) ; for ( int i = 0 ; i < fArray . length ; ++ i ) { iStream . read ( bbArray ) ; bbuf . rewind ( ) ; fbuf . get ( fArray [ i ] ) ; fbuf . rewind ( ) ; } break ; case colorimage : int [ ] [ ] iArray = ( int [ ] [ ] ) raster ; bbArray = new byte [ iArray [ 0 ] . length * 4 ] ; bbuf = ByteBuffer . wrap ( bbArray ) ; IntBuffer ibuf = bbuf . asIntBuffer ( ) ; for ( int i = 0 ; i < iArray . length ; ++ i ) { iStream . read ( bbArray ) ; bbuf . rewind ( ) ; ibuf . get ( iArray [ i ] ) ; ibuf . rewind ( ) ; } break ; case grayimage : byte [ ] [ ] bArray = ( byte [ ] [ ] ) raster ; for ( int i = 0 ; i < bArray . length ; ++ i ) { iStream . read ( bArray [ i ] ) ; } break ; } iStream . close ( ) ; }
read the padded raster file .
