1
我正在开发一个项目并拥有一个验证xml文件的类,但它们来自webPage,并从一个webmail下载并保存在临时文件夹中。获取我的JSF项目中的文件夹路径
我的问题是,如果我通过应用程序获取文件,我可以让我的xsd文件进行验证。但通过电子邮件下载,他们不会加载我的文件。
但我怎样才能得到这些文件在我的资源文件夹?
public static String xsdFile(File file) {
String rootElement = getRootElement(file);
String rootVersion = getVersion(file);
String realPath = "";
try {
realPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(xsdPath);
} catch (Exception e) {
String path = XmlUtil.class.getClassLoader().getResource("").getPath().replaceAll("classes/", "");
path = path.concat(xsdPath).concat(rootVersion).concat("/").concat(rootElement).concat(".xsd");
File teste = new File(path);
if (teste.exists()) {
System.out.println("found");
}
return path.concat ("/").concat(rootVersion).concat("/").concat(rootElement).concat(".xsd");
}
return realPath.concat("\\").concat(rootVersion).concat("\\").concat(rootElement).concat(".xsd");
}