📄 stringoper.java
字号:
package net.aetherial.gis.publicuse;
import java.io.File;
/**
* <p>Title: </p>
*
* <p>Description: 操作字符串</p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class StringOper {
public StringOper() {
}
/**
* 删除掉字符串中所有的某个特定字符,字符串长度将 -1;
*/
public static String deleteAllChar(String string, char ch) {
char[] array = string.toCharArray();
if (array != null) {
for (int i = 0; i < array.length; i++) {
if (array[i] == ch) {
array = getRidofChar(array, i);
i--;
}
}
return new String(array);
}
else {
return string;
}
}
/**
* 删除掉字符数组中某个特定位置字符,字符数组长度将 -1;
*/
public static char[] getRidofChar(char[] array, int index) {
if (array.length <= 1) {
return null;
}
else {
char[] temp = new char[array.length - 1];
for (int i = 0; i < temp.length; i++) {
if (i < index) {
temp[i] = array[i];
}
else {
temp[i] = array[i + 1];
}
}
return temp;
}
}
/**
* 判断两字符串是否相同,或者其中一个包含另外一个
*/
public static boolean isInclude(String str1, String str2) {
if (str1 == null || str2 == null || "".equals(str1) || "".equals(str2)) {
return false;
}
if (str1.indexOf(str2) != -1) {
return true;
}
else if (str2.indexOf(str1) != -1) {
return true;
}
else {
return false;
}
}
/**
* 得到带有\\结尾的路径
*/
public static String getSplashPath(String path) {
if (path.endsWith("\\") || path.endsWith("/")) {
return path;
}
else {
return path + "\\";
}
}
/**
* 得到带有\\结尾的路径
*/
public static String getSplashPath(File path) {
return getSplashPath(path);
}
/**
* 得到被替换的路径
*/
public static File getReplacePathFile(String inputPath,String outPath,File openFile){
String of = openFile.getAbsolutePath();
inputPath = getSplashPath(inputPath);
outPath = getSplashPath(outPath);
of = outPath + of.substring(inputPath.length(),of.length());
return new File(of);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -