The BufferedImage class has an int getRGB(int x, int y) method int getRGB(int x, int y) that returns a hexadecimal integer representing the pixel color in (x, y) (and another method that returns a pixel matrix). From this you can get the values of r, g and b as follows:
int r = (0x00ff0000 & rgb) >> 16;
int g = (0x0000ff00 & rgb) >> 8;
int b = (0x000000ff & rgb);
and then check if they are all equal for each pixel in the image. If r == g == b for each pixel, then it is in gray scale.
This is the first thing that comes to mind. I'm not sure if any grayscale flag will be set when reading in the image.
source share