HTTP错误:java.lang.IllegalArgumentException: Illegal character in scheme at index 0: http://xxxxxx
读取T卡文件里的域名,HTTP请求出现如下错误
java.lang.IllegalArgumentException: Illegal character in scheme at index 0: http://xxxxxxxxxxx
at java.net.URI.create(URI.java:727)
at org.apache.http.client.methods.HttpPost.<init>(HttpPost.java:84)
......
出现该错误时,读取域名的代码如下
protected String getFileContent(File file) {
String content = "";
if (file.isDirectory() ) { //检查此路径名的文件是否是一个目录(文件夹)
Log.i("zeng", "The File doesn't not exist "
+file.getName().toString()+file.getPath().toString());
} else {
if (file.getName().endsWith(".txt")) {//文件格式为txt文件
try {
InputStream instream = new FileInputStream(file);
if (instream != null) {
InputStreamReader inputreader
=new InputStreamReader(instream, "UTF-8");
BufferedReader buffreader = new BufferedReader(inputreader);
String line="";
//分行读取
while (( line = buffreader.readLine()) != null) {
content += line + "\n";
}
instream.close(); //关闭输入流
}
}
catch (java.io.FileNotFoundException e) {
Log.d("TestFile", "The File doesn't not exist.");
}
catch (IOException e) {
Log.d("TestFile", e.getMessage());
}
}
}
return content ;
}
修改为如下方法后,HTTP请求正常
private static String getFileContent(File file) {
String content = "";
try {
FileInputStream fin = new FileInputStream(file);
int length;
length = fin.available();
byte [] buffer = new byte[length];
fin.read(buffer);
content = EncodingUtils.getString(buffer, "UTF-8");
fin.close();
return content;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return content;
}
HTTP错误:java.lang.IllegalArgumentException: Illegal character in scheme at index 0: http://xxxxxx的更多相关文章
- java.lang.IllegalArgumentException: Illegal character in query at index ...解决办法
今天在写智能机器人问答实现的时候遇到了一个问题,就是我发送消息不能输入空格 给我报了一个错误java.lang.IllegalArgumentException: Illegal character ...
- java.lang.IllegalArgumentException: Illegal character in query at index 261
在BaseFragment中使用了LoadingPage,而LoadingPage的联网加载使用的是AsyncHttpClient.一直报java.lang.IllegalArgumentExcept ...
- 问题记录——java.lang.IllegalArgumentException: Illegal character in scheme name at index 0
以下http请求报错是因为,请求的地址前面有个空格.... 2019-01-09 03:30:23,154 ERROR [business.modules.merchantreportresult.s ...
- Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in query at index 189......
Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in query ...
- java爬虫出现java.lang.IllegalArgumentException: Illegal character in path at index 31
url地址中出现了空格,使用trim()函数去除空格就好了
- Cookie存储中文报错:java.lang.IllegalArgumentException: Control character in cookie value or attribute.(转)
项目中做自动登录和保存密码时,Cookie报错Java.lang.IllegalArgumentException,上google查了下 在http://hi.baidu.com/xtxycy/blo ...
- Tomcat v7.0 java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
十二月 , :: 下午 org.apache.coyote.http11.AbstractHttp11Processor process 信息: Error parsing HTTP request ...
- java.lang.IllegalArgumentException: Invalid character found in method name
1.错误描述 信息: Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors ...
- 后台报错java.lang.IllegalArgumentException: Invalid character found in the request target.
报错: Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. java.lang ...
随机推荐
- aspx子集页面找父级页面元素
var Obj= window.parent.document.getElementById("ctl00_RightTopTree_hidJsonResult"); Obj.va ...
- html5 input 标签
<!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content ...
- Git之远程项目克隆到本地配置
远程代码克隆到本地工作区,需要进行简单的配置,用于识别身份 1.git config --global user.name [设置用户名,你的github用户名] 2.git config -- ...
- CF749C Voting
题目链接: http://codeforces.com/problemset/problem/749/C 题目大意: 共有n个人,编号为1~n.他们每个人属于且仅属于R阵营或N阵营中的一个.现在他们要 ...
- Git-往返github和本地
将GitHub仓库Test弄到本地 本地新建文件夹Test 右击运行gitbash 在gitbash中输入git init 在github 仓库选择clone or download 复制链接http ...
- JD IPO address by liuqiangdong
Ladies and gentlemen, Good evening.I'd rather use english, not mandarin.Because during the road show ...
- 盘点那些年,被Oracle收购的公司
微博上看到一图,很清晰.盘点那些年,被Oracle收购的公司,Oracle日益强大,都收购了哪些公司呢?别再以为只有Sun啦...看看你都知道哪些? ps:Strategic Acquisitions ...
- Hibernate懒加载深入分析
Hibernate懒加载深入分析 懒加载可以提高性能吗? 不可以简单的说"能",因为Hibernate的关系映射拖累了SQL的性能,所以想出懒加载来弥补.只是弥补而以,不会超越. ...
- (转)配置Spring管理的bean的作用域
http://blog.csdn.net/yerenyuan_pku/article/details/52833477 Spring管理的bean的作用域有: singleton 在每个Spring ...
- 1-1 编程基础 GCC程序编译
GCC简介 Linux系统下的gcc是GNU推出的强大.性能优越的多平台编译器,是GNU的代表作之一.gcc可以在多种硬体平台上编译出可执行程序,其执行效率与一般的编译器相比平局效率要高20 ...