replace.java
来自「java 调用windows的api」· Java 代码 · 共 41 行
JAVA
41 行
package org.jawin.browser.util;
/**
* <p>Title: Jawin Code Generation GUI</p>
* <p>Description: GUI for exploring type libraries and generating Java code</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Open Source Incentive</p>
* @author Josh Passenger
* @version 1.0
*/
public class Replace extends Exception {
public Replace()
{
}
public static String replace(String raw, String replace, String with)
{
StringBuffer buffer = new StringBuffer();
if (with.indexOf(replace) != -1)
{
throw new IllegalArgumentException("Replace.replace() the replacement (" + with + ") contains the String to replace (" + replace + ")");
}
int index = raw.indexOf(replace);
while (index > -1)
{
buffer.setLength(0);
buffer.append(raw.substring(0, index));
buffer.append(with);
buffer.append(raw.substring(index + replace.length()));
raw = buffer.toString();
index = raw.indexOf(replace);
}
return raw;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?