81,091
社区成员
发帖
与我相关
我的任务
分享
public String execute() throws Exception {
String str;
//URI uri=null;
String path=null;
try {
str = this.getClass().getResource("/").getPath();
str=str+"../../../test.xml";
path=URLDecoder.decode(str, "utf-8");
System.out.println(path);
File file=new File(path);
if(file.exists())
{
System.out.println("true");
}else
{
System.out.println("false");
}
}catch(Exception e)
{
e.printStackTrace();
}
return SUCCESS;
}
this.getClass().getResource("test.xml").getPath();
public String execute() throws Exception {
String str=this.getClass().getResource("/").toURI().toString();
str=str+"../../../abc.xml";
URI uri=new URI(str);
File f=new File(uri);
System.out.println(f.exists());
File f2=new File("/d:/1.txt");
System.out.println(f2.exists());
return SUCCESS;
}