Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Main {
    public static void main(String args[]) throws IOException {
        File file = new File("your file path.jpg");
        BufferedImage image = ImageIO.read(file);

        for (int i = 0; i < image.getHeight(); i++) {
            for (int j = 0; j < image.getWidth(); j++) {
                int color = image.getRGB(j, i);
                // convert the color to a readable format
                String clr = Integer.toHexString(color).substring(2);
                System.out.println(clr);
            }
        }
    }
}