Java tutorial
//package com.java2s; public class Main { public static String getValuePhoto(String value, int heightImage, int widthImage) { if (value != null) { if (!value.equals("")) { int indexHeight = value.indexOf("height"); int indexWidth = value.indexOf("width"); if (indexHeight < 0 && indexWidth < 0) { return value.replaceAll(">", " height=\"" + heightImage + "\"" + " width=\"" + widthImage + "\"" + " >"); } else { if (indexHeight < indexWidth) { return value.toString().replace( value.toString().substring(value.toString().indexOf("height"), value.toString().indexOf(">")), " height=\"" + heightImage + "\"" + " width=\"" + widthImage + "\"" + " "); } else { return value.toString().replace( value.toString().substring(value.toString().indexOf("width"), value.toString().indexOf(">")), " height=\"" + heightImage + "\"" + " width=\"" + widthImage + "\"" + " "); } } } else { return ""; } } else { return ""; } } }