public static void replaceColor(String regex,String colorcode) {//regex是要替换的字符串正则表达式,colorcode是要替换成的字符串
String temp = "";
try {
File file = new File(System.getProperties().getProperty("catalina.base")+"//deploy//eartest.ear//jsptest.war//"+"allstyle//style.css");
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
StringBuffer buf = new StringBuffer();
while((temp=br.readLine())!=null)
{
buf.append(temp);
}
String filestr= buf.toString().replaceAll(regex, colorcode);
FileOutputStream fos = new FileOutputStream(file);
fos.write(filestr.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
替换css 文件中的内容
最新推荐文章于 2024-04-06 11:09:44 发布