Run the following command to import the Certificate file to jdk:
Keytool-import-alias 12306-keystore cacerts-file D: \ srca12306 \ srca. cer-trustcacerts
Keytool-import-keystore % JAVA_HOME % \ jre \ lib \ security \ cacerts-file D: \ srca12306 \ srca. cer-alias 12307
Keytool-import-keystore cacerts-file D: \ srca12306 \ srca. cer-alias 12307
The default jdk keystore password is changeit.
HttpsURLConnection Chinese garbled Problem
Public class httpUTIL {private String url; private URL myurl; private boolean is_ OK; // private HttpsURLConnection https; public httpUTIL (String url) {this. url = url; https = null;} public void init () throws MalformedURLException {myurl = new URL (url); try {https = (HttpsURLConnection) myurl. openConnection (); https. setRequestProperty ("Accept-Language", "zh-CN"); // https. setRequestProperty ("content Type "," GBK "); https. setRequestProperty ("Charset", "UTF-8"); if (https. getResponseCode () = https. HTTP_ OK) {is_ OK = true;} elseis_ OK = false;} catch (IOException e) {// TODO Auto-generated catch blocke. printStackTrace () ;}} public HttpsURLConnection gethttps () {return https;} public boolean gethttp_status () {return is_ OK;} public static void main (String args []) {String url = bookInfo. book_init; httpUTIL htt P = new httpUTIL (url); HttpsURLConnection httpscon; StringBuilder testhtml = new StringBuilder (""); InputStream in; BufferedReader buffread; try {http. init (); httpscon = http. gethttps (); if (httpscon = null) {System. out. println ("https null"); return;} httpscon. connect (); in = httpscon. getInputStream (); if (in = null) {System. out. println ("in null"); return;} buffread = new BufferedReader (new InputStreamReader (in, "UTF-8 "); // Encoding problem. It will be okay to handle it here. It's good. The stream is transcoded String line; line = buffread. readLine (); while (line! = Null) {testhtml. append (line); line = buffread. readLine ();} // System. out. println (testhtml); String strtest = testhtml. toString (); System. out. println (strtest); int a = strtest. indexOf ("arriving at Station"); int B = testhtml. indexOf ("html"); // how can this problem be solved? garbled characters are displayed in Chinese and the Chinese character System cannot be found. out. println ("Hangzhou" + a + "" + B); String str = "test + Hangzhou" + "test"; int c = str. indexOf ("Hangzhou"); System. out. println (c); if (httpscon! = Null) {httpscon. disconnect () ;}} catch (IOException e) {// TODO Auto-generated catch blocke. printStackTrace ();}}}