Because of the project needs, the internal information system for the front-end file archiving, CSS file archiving, along with the changes in the image URL, because the system in the CSS contains a URL: (.. /ui/images/excel.jpg) and other relative paths.
It is therefore necessary to replace such a situation with three known parameters in the function:
1, the original CSS absolute path
2. URL of background image in CSS file
3, the absolute path after the CSS archive
The code is as follows:
/******************************************************************************* * $Header $ * $Revision $ * $Date $ * *= ============================================================================= * * Copyright (c) 2001-2006 Primeton Technologies, Ltd. * All rights reserved. * * Created on 2015-2-9 *******************************************************************************/package org.gocom.bpm.platform.test;/** * * * 2015-2-9 a.m. 09:07:35 */public class Imagepathmatch {public static void main (string[ ] args) {String src = "/eos-default/ui/style/commons.css"; String image = ".. /images/null.gif "; String dest = "/EOS-DEFAULT/UI/ARCHIVE/UI/STYLE/COMMONS.CSS";/* * 1, gets the absolute path of the image * 2, compares the source path and the destination path hierarchy * 3, obtains the last image relative path */strin g[] arrsrc = Src.split ("/"); string[] Arrimage = Image.split ("/"); int i=arrsrc.length,j=arrimage.length;int p = 0,q=1; StringBuilder sb = new StringBuilder, Sb.append ("/"); for (int k=0;k<j;k++) {if (Arrimage[k].equals ("..")) {p+=1;}} while ((q+p*2) <i) {Sb.append (arrsrc[q++]). Append ("/");} while (p<j) {sb.append (arrimage[p++]), if (p<j) sb.append ("/");} System.out.println (Sb.tostring ()); String Midpath = sb.tostring (); Sb.delete (0, Sb.length ()); string[] Arrmid = Midpath.split ("/"); string[] Arrdest = Dest.split ("/"); Boolean flag = true; Q =0; while (flag) {if (Arrmid[q].equals (Arrdest[q])) Q + +; else flag = false;} p = arrdest.length; int s = q; while (q<p) {Sb.append (".."). Append ("/"); q + +;} p = Arrmid.length;s = S-1, while (s<p) {sb.append (arrmid[s++]), if (S < p) Sb.append ("/");} System.out.println (Sb.tostring ());}}
CSS Archiving of archive functions