美文网首页
getClassLoader() 的getResource 中文

getClassLoader() 的getResource 中文

作者: 左洁 | 来源:发表于2017-10-27 17:08 被阅读0次

    URL url =this.getClass().getClassLoader().getResource("/"+ basePackageName.replaceAll("\\.","/"));

    String pathFile = url.getFile();  //如果是中文路径 pathfile是路径里面是乱码

    //需要进行decode才能正常显示中文路径

    String urlPath=java.net.URLDecoder.decode(pathFile,"utf-8");

    参考链接  http://blog.sina.com.cn/s/blog_67cc72cc0101ejie.html

    相关文章

      网友评论

          本文标题:getClassLoader() 的getResource 中文

          本文链接:https://www.haomeiwen.com/subject/dlwosxtx.html