1.创建临时目录
//创建临时目录
try {
Path path =Files.createTempDirectory(Client.class.getName());
System.out.println(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
结果:
d:\Users\shuqiang.zhu\AppData\Local\Temp\test.Client8944018103767412316 //目录名称 包名+类名+随机值
2.正则表达式的组
//测试正则表达式
String SlippingWindowPointOprand = "\\(\\s*\"([^\"\\s]+)\"\\s*,";
String SlippingWindowPointCollectOprand = SlippingWindowPointOprand + "\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)";
Matcher matcher1 = Pattern.compile(SlippingWindowPointOprand).matcher("( \"123\" ,");
Matcher matcher2 = Pattern.compile(SlippingWindowPointCollectOprand).matcher("( \"123\" , 123 , 123 )");
System.out.println(SlippingWindowPointOprand);
//该方法必须提前调用,下面方法依赖该方法的结果
if(matcher1.matches())
{
for(int i=0;i<=matcher1.groupCount();i++)
System.out.println("第"+i+"组,"+matcher1.group(i));
}
if(matcher2.matches())
{
for(int i=0;i<=matcher2.groupCount();i++)
System.out.println("第"+i+"组,"+matcher2.group(i));
}
结果:
第0组,( "123" ,
第1组,123
第0组,( "123" , 123 , 123 )
第1组,123
第2组,123
第3组,123