异常:java.lang.IllegalArgumentException: URI scheme is not “file”?的解决方案
来源:互联网 发布:淘宝店铺手机登陆 编辑:程序博客网 时间:2024/04/30 08:07
异常:java.lang.IllegalArgumentException: URI scheme is not “file”?
这个异常是由这两句代码引起的。
URL url = QueryParser.class.getResource(Querys.QUERY_FILE_PATH);
InputStream in = new FileInputStream(new File(url.toURI()));
可以理解为对于使用getgetResource方法获得文件url,两种服务器对url的前缀做出了不同的处理。
url的前缀模式不止一种,比如file//和http://。对于new File(url.toURI())这条语句,url的前缀必须是file//,
所以对于语句new File(new URI("file:///etc/passwd"))能运行,而对于语句
new File(new URl("http://localhost/etc/passwd"))则不能运行。因此,我们不能始终认为url的前缀是file//,
对于new File(url.toURI())的运用也要特别注意。如果使用InputStream is = url.openStream();就不会出现异常。
- 异常:java.lang.IllegalArgumentException: URI scheme is not “file”?的解决方案
- java.lang.IllegalArgumentException: URI is not hierarchical
- java.lang.IllegalArgumentException: The observer is null.异常解决方案
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base *** does not exist or is not a readable
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base *** does not exist or is not a readable
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base *** does not exist or is not a readabl
- Tomcat的异常 之 java.lang.IllegalArgumentException:Document base *** does not exist or is not a readable
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base xxx does not exist or is not a readab
- 【Android】java.lang.IllegalArgumentException Illegal character in scheme 异常
- apache的httpclient报出的java.lang.IllegalArgumentException: Invalid uri ...... escaped absolute path not valid
- java.lang.IllegalArgumentException: AppIndex: The URI scheme must be 'android-app' and follow the fo
- java.lang.IllegalArgumentException: Invalid uri ......
- 异常:java.lang.IllegalArgumentException
- tomcat的java.lang.IllegalArgumentException:Document base *** does not exist or is not a readable
- 解决spring的java.lang.IllegalArgumentException异常。
- 解决spring的java.lang.IllegalArgumentException异常。
- 解决Spring的java.lang.IllegalArgumentException异常
- java.lang.IllegalArgumentException: The observer is null.最终解决方案
- Python列表list 数组array常用操作集锦
- XTUOJ 1168 填颜色
- 现在的车模呀越来越露了
- test3-6(任务)
- iOS 设置中文包
- 异常:java.lang.IllegalArgumentException: URI scheme is not “file”?的解决方案
- linux操作系统学习网站整理(100个)
- 第14周项目13-字符统计(三)
- RH436之Udev设备管理之概念
- 策略模式
- test3-7(污损的数字)
- test3-8(可逆素数)
- 搜狗2014年笔试题-两递增数组A和B,求A[i]+B[j]中前k个最小值(Java)
- enumerrate 用法