⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringreplace.java

📁 图书馆检索系统
💻 JAVA
字号:
/** StringReplace.java**/package library;/**** Performs string replacement.  The* methods contained in this class* must be left non-static to allow* for usage from a JSP, even though* it makes more sense to be static.** @author dms* @version 1.0**/public class StringReplace {  /**  * A generic, variable length,  * String replacement function.  * Primarily a helper function  * for the escape/unescape duo,  * this was left public since  * it may be of some use on its own.  * @param s 	String to perform replacement on  * @param seq   String sequence to look for  * @param rep   String to replace with  * @return String with replacements  */  public static String replace(String s, String seq, String rep) {    int index = 0;    StringBuffer sb = new StringBuffer();    if (s.length() >= seq.length()) {      do {        int next = s.indexOf(seq, index);        if (next == -1) {          sb.append(s.substring(index));          break;        } else if (next == index) {          sb.append(rep);          index += seq.length();        } else {          sb.append(s.substring(index, next));          sb.append(rep);          index = next + seq.length();        }      } while (index != -1);    } else {      sb.append(s);    }    return sb.toString();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -