我该如何解决 java.lang.IllegalArgumentException: 协议 = https 主持人 = null 一个例外?
我在客户端 - 服务器程序上工作 SSL, 而且我需要重复使用以下方法。
这里 ServerURL 初始化为
当我尝试完成此方法时,我在字符串中获得异常,
OutputStream 轴 = conn.getOutputStream//;
例外是
这是什么原因?
private boolean postMessage/String message/{
try{
String serverURLS = getRecipientURL/message/;
serverURLS = "https:\\\\abc.my.domain.com:55555\\update";
if /serverURLS != null/{
serverURL = new URL/serverURLS/;
}
HttpsURLConnection conn = /HttpsURLConnection/serverURL.openConnection//;
conn.setHostnameVerifier/new HostnameVerifier// {
public boolean verify/String arg0, SSLSession arg1/ {
return true;
}
}/;
conn.setDoOutput/true/;
OutputStream os = conn.getOutputStream//;
OutputStreamWriter wr = new OutputStreamWriter/os/;
wr.write/message/;
wr.flush//;
if /conn.getResponseCode// != HttpsURLConnection.HTTP_OK/
return false;
else
return true;
}
这里 ServerURL 初始化为
private URL serverURL = null;
当我尝试完成此方法时,我在字符串中获得异常,
OutputStream 轴 = conn.getOutputStream//;
例外是
java.lang.IllegalArgumentException: protocol = https host = null
这是什么原因?
没有找到相关结果
已邀请:
2 个回复
江南孤鹜
赞同来自:
你收到错误的原因是课程 URL 不能拆卸线的主要部分,因此
-这是
.
帅驴
赞同来自:
分配结果
然后你立即覆盖价值
, 制作前一个陈述
http://en.wikipedia.org/wiki/Dead_store
然后,自该价值
一样
, 自从你
只要
以前的运算符中指定的变量值,为您分配值
. 这是不可能的
比率之前
!
事实上,你永远不会使用变量
在代码的前一行之外。
你可以替换所有这个简单: