0
我必須使用https協議和java中的基本認證來檢索csv。我使用這個代碼,但輸出流retrived是一個250零的數組。我的代碼中有一些錯誤?https協議和java中的基本認證問題
String webPage = url_a;
String name = email;
String password = pass;
String authString = name + ":" + password;
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
URL url = new URL(webPage);
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.addRequestProperty("Authorization", "Basic " + authStringEnc);
urlConnection.setRequestMethod("POST");
urlConnection.setAllowUserInteraction(false);
urlConnection.setDoInput(false);
urlConnection.setDoOutput(true);
urlConnection.connect();
final OutputStream outs = urlConnection.getOutputStream();
謝謝你,那是一個非常愚蠢的錯誤,正在殺死我XDXD – user3483967