当前位置: 代码迷 >> Web前端 >> JAVA彻底解决获取空格路径有关问题
  详细解决方案

JAVA彻底解决获取空格路径有关问题

热度:95   发布时间:2012-09-15 19:09:28.0
JAVA彻底解决获取空格路径问题
ReadProperties read = new ReadProperties("db");
		double currentVersion = Double.valueOf(read.readProperties("Version"));
		if (version <= currentVersion) {
			String path = Thread.currentThread().getContextClassLoader()
					.getResource("").toString();//获取更目录地址
			path = path.substring(path.indexOf("/") + 1, path.length()) + "pda";
			try {
				path = URLDecoder.decode(path, "utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}// 关键啊 !主要转换文件地址,避免空格问题
			System.out.println(path);


D:/D/Java/Apache/apache-tomcat-7.0.20 - Copy/webapps/xhsd/WEB-INF/classes/pda
  相关解决方案