获取类路径:
ReqTextMessage.class.getResource("") .getPath();
获取系统目前路径
File dir = new File("");
dir.getAbsolutePath();
创建文件
String filename= dir.getAbsolutePath()+ "/src/main/resources/requtet.xml" ;
File file = new File(filename);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}