替换html 中的图片

xiaoxiao2022-06-16  79

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图片缓存,替换加载前默认图片的样式
转载请注明原文地址: https://www.6miu.com/read-4940919.html

最新回复(0)