java 文件加载 windows 和linux下
xml文件和启动文件在同一包下:
public static InputStream getOadXmlPath() throws FileNotFoundException { InputStream in = null; String fileName = "OADMapping.xml"; String os = System.getProperty("os.name"); if (os != null && os.toLowerCase().startsWith("windows")) { String filePath = System.getProperty("user.dir") + File.separator + "src/main/com/adao/dataprocess/" + fileName; File file = new File(filePath); in = new FileInputStream(file); } else if (os != null && os.toLowerCase().startsWith("linux")) { in = Application.class.getResourceAsStream(fileName); } return in; }