读取src下的xml文件

	public String getSaveURL(String fileType){
		String uploadURL = "";		
		try {
			SAXReader reader = new SAXReader();
			Document document = reader.read(new File(getClass().getClassLoader().getResource("uploadConfig.xml").getPath()));
			uploadURL = document.getRootElement().elementText(fileType);
		} catch (DocumentException e) {
			e.printStackTrace();
		}
		return uploadURL;
	}


调试代码
File f = new File(getClass().getClassLoader().getResource("uploadConfig.xml").getPath())
String absolutePath = f.getAbsolutePath();
System.out.println(absolutePath);

你可能感兴趣的:(java,xml,F#)