/**
* 将空格转换为%20
*
* @param s
* @return
*/
public String delEnt(String s) {
Pattern pattern = Pattern.compile(
"s*\\+");
Matcher matcher =
pattern.matcher(s);
return matcher.replaceAll(
"%20");
}
/**
* 去掉换行符
*
* @param s
* @return
*/
public String delEn(String s) {
Pattern pattern = Pattern.compile(
"\\s*\n");
Matcher matcher =
pattern.matcher(s);
return matcher.replaceAll(
"");
}
/**
* 删除rar,srt类型文件
*
* @param s
* @return
*/
public String[] removeRAR(String[] s) {
List<String> lista =
new ArrayList<String>
();
for (
int i =
0; i < s.length; i++
)
lista.add(s[i]);
for (
int j =
0; j < s.length; j++
) {
if (s[j].indexOf(
".rar") != -
1 || s[j].indexOf(
".srt") != -
1) {
lista.remove(s[j]);
}
/**
* 汉字转码
*
* @param str
* @return
*/
public String strToUTF(String str) {
try {
str = URLEncoder.encode(str,
"UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.d(str, "");
return str;
}
}
final int size =
lista.size();
s = (String[]) lista.toArray(
new String[size]);
return s;
}
转载于:https://www.cnblogs.com/wuyihong/archive/2012/06/29/2569941.html
相关资源:文本文件编码转换工具 gbk utf8 gb2312