public static String getFileName( String pathKey, String fileNmKey, HttpServlet servlet) { String configBundleNm = "存放文件路径及文件名的资源文件名"; String fullName = null;
try { PropertyResourceBundle configBundle = (PropertyResourceBundle) PropertyResourceBundle.getBundle( configBundleNm, Locale.getDefault());
String fileName = (String) configBundle.getString(fileNmKey).trim(); String path = (String) configBundle.getString(pathKey).trim(); String fullPath = servlet.getServletContext().getRealPath(path); String fileSeparator = System.getProperties().getProperty("file.separator"); fullName = new StringBuffer() .append(fullPath) .append(fileSeparator) .append(fileName) .toString(); } catch (MissingResourceException missE) {
}
File file = new File(fullName); if (!file.isFile()) {
}
return fullName;
}
|