我拥有这样的宁静的代码,可以抛出java.lang.StringIndexOutOfBoundsException: String index out of range: -1
URL url = new URL(serverURL);
// open a connection to that source
URLConnection urlConnection = url.openConnection();
HttpsURLConnection.setDefaultHostnameVerifier(
new javax.net.ssl.HostnameVerifier(){
public boolean verify(String hostname,
javax.net.ssl.SSLSession sslSession) {
return true;
}
});
HttpsURLConnection con = (HttpsURLConnection) urlConnection;
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[] { new SffX509TrustManager(TQLCLI.localConfig) }, new SecureRandom());
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
con.setSSLSocketFactory(sslSocketFactory);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[] { new SffX509TrustManager(TQLCLI.localConfig) }, new SecureRandom());
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
con.setSSLSocketFactory(sslSocketFactory);
// Exception throws somewhere in the following line
con.setRequestMethod("POST");
con.setDoOutput(true);
OutputStream outStream = con.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(outStream);
osw.write(postBody);
osw.flush();
osw.close();
outStream.close();
con.connect();
BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStream()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
con.disconnect();
// System.out.println(result.toString());
return result.toString();
在第outStream = con.getOutputStream();
行,其抛出java.lang.StringIndexOutOfBoundsException
您在此代码段中是否看到任何会引起StringIndexOutOfBoundsException
的问题?