📄 helptools.java
字号:
/*
* Created on 2006-8-23
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package net.excel.report.util;
/**
* TODO :工具类,放一些共用函数。
* @author juny
*/
public class HelpTools {
/**
* 一个仿jdk1.5 String.replace()功能的函数, 为了能在jdk1.4下运行.<br>
* 用法示例:<br>
* String source = "This is string abc";<br>
* String needReplace = "abc";<br>
* String replaceWith = "ABC";<br>
* source = HelpTools.replace(source, needReplace, replaceWith);<br>
* 执行后source的结果为:"This is string ABC"<br>
* @since 1.0
* @param source 被替换的源字符串。
* @param target 需被替换的字符串。
* @param replaceWith 替换源字符串的新字符串
* @return:替换后的新字符串。
*/
public static String replace(CharSequence source, CharSequence target,
CharSequence replaceWith){
if(null == target || null == replaceWith || null == source){
throw new NullPointerException();
}
String strTarget = target.toString();
String strReplaceWith = replaceWith.toString();
StringBuffer src = new StringBuffer(source.toString());
int pos = 0;
pos = src.indexOf(strTarget);
while (pos >= 0) {
src = src.replace(pos, pos + strTarget.length(), strReplaceWith);
pos = src.indexOf(strTarget);
}
return src.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -