正则表达式
- 空格
多个空格
String[] strTemp = str.split("\\s+"); 
  - 匹配数字
"1".matches("\\d");		//true // String是小于10的正整数
"111".matches("\\d");	//false 
"111".matches("\\d+");	//true // String是正整数
"-1".matches("\\d+");	//false
"1.1".matches("\\d+");	//false
"a".matches("\\D");		//true // String是一个字符
"1".matches("\\D");	//false
"aaa".matches("\\D");	//false
"aaa".matches("\\D+");	//true // String是字符串
"11".matches("\\D+");	//false
    编码
路径格式
- 获得当前类路径
 - 获得从bin路径开始的文件路径
 
“/” - - - Runner类文件存放的目录,即bin
“/config.txt” - - - bin目录/config.txt
package cn.edut.com.tarena;
import java.net.URL;
import java.net.URLDecoder;
public class Runner {
	static {
		try {
			/* * "/" --- Runner类文件存放的目录,即bin "/config.tst" --- bin目录/config.txt */
			URL url = Runner.class.getResource("/config.txt");
			String path = url.getPath();
			// "d:/中/bin/config.txt" ---URL编码---> "d:/%E4%B8%AD/bin/config.txt"
			// ---编码---> "d:/中/bin/config.txt"
			// decode 解码
			path = URLDecoder.decode(path, "utf-8");
			System.out.println(path);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
	}
}
  
京公网安备 11010502036488号