Java tutorial
//package com.java2s; import java.io.File; public class Main { private static final int KB_10 = 10240; private static final int MB_5 = 10485760; public static boolean validImage(String path, String url, int res) { if (0 != res) { return true; } else if (null != path && path.length() != 0 && path.length() < KB_10) { final File file = new File(path); if (!(file.exists() && file.length() < MB_5)) { if (null != url && url.length() != 0) { return true; } } return true; } else if (null != url && url.length() != 0) { return true; } return false; } }