Java tutorial
//package com.java2s; public class Main { public static String[] IMAGE_END = new String[] { ".png", ".jpg", ".jpeg" }; public static String appendJPG(String url) { try { for (String m : IMAGE_END) { if (url.endsWith(m)) { return url; } } url = url + ".jpg"; return url; } catch (Exception e) { return url; } } }