public static void main(String[] args) { String temp = "<p><img height=\"600\" width=\"800\" alt=\"\" sRc=\"/adc_op/UserFiles/Image/Sunset.jpg\" /></p>" +"<p><ImG height=\"600\" width=\"800\" alt=\"\" sRc=\"/adc_op/UserFiles/Image/Sunset.jpg\" /></p>"; System.out.println(replaceStr(temp,"","","http://10.30.3.236:8888")); } public static String replaceStr(String oriStr , String flag , String postionStr , String replaceStr) { String tempStr = oriStr.toUpperCase(); StringBuffer desStr = new StringBuffer(); int i = 0; while ( (i = tempStr.indexOf("<IMG")) != -1 ) { i = tempStr.indexOf("SRC"); desStr.append(oriStr.substring(0,i+5)); desStr.append(replaceStr); tempStr = tempStr.substring(i+5); oriStr = oriStr.substring(i+5); } desStr.append(oriStr); return desStr.toString(); }
相关资源:Android实现WebView图片缓存,替换加载前默认图片的样式