Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.net.URL;

public class Main {
    public static String getImageDimension(String imgLocation) throws Exception {
        BufferedImage image = null;
        try {
            image = ImageIO.read(new URL(imgLocation));
        } catch (Exception e) {
            // If an error occurs, we consider the image as null. - FB
        }
        return (image == null ? "-1,-1" : image.getWidth() + "," + image.getHeight());
    }
}