Here you can find the source of getRandomPixel(final String fileName)
public static String getRandomPixel(final String fileName) throws IOException
//package com.java2s; //License from project: Apache License import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; public class Main { private static BufferedImage img; private static String file; public static String getRandomPixel(final String fileName) throws IOException { if (!fileName.equals(file)) { img = ImageIO.read(new File(fileName)); file = fileName;/* w w w.j a va2 s . c om*/ } return String.format("#%06X", (0xFFFFFF & img.getRGB((int) (Math.random() * img.getWidth()), (int) (Math.random() * img.getHeight())))); } }