CSS Archiving of archive functions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.