Getting the image width or height

Hi all,



currently reading in a png and trying to get the width / height of the image.

Is there anyway to do this dynamicly, cause eventually i've loads of images that need to be processed.



What i try is the following.





public static Image ReadInImage(URI u) throws IOException {

   FileInputStream FIS = new FileInputStream( new File(u.getPath() ) );
   byte[] b = new byte[8192];
   int readIn;
   int bytesAvailable = FIS.available();
   ByteBuffer byteBuffer = ByteBuffer.allocate( bytesAvailable );
      
   while ( (readIn = FIS.read(b) ) != -1 )
   {
      byteBuffer.putInt(readIn);
      //System.out.println(readIn);
   }

   Image img = new Image();
   img.addData(byteBuffer);
      
   return img;
}



again thanks in advance,

Wizard