我正在使用以下代码段,
URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
urlConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=");
BufferedOutputStream bos = new BufferedOutputStream(urlConnection.getOutputStream());
try {
// reqEntity.writeTo(bos); which method shall I use instead of writeTo();
} finally {
bos.close();
bos.flush();
}
在MultipartEntityBuilder
中,没有名为writeTo(BufferedOutputStream bos)的方法,那么我应该使用哪种方法来使其工作?
注:
MultipartEntity is deprecated now from Android api-level 23 and above.
答案 0 :(得分:0)
您必须如此构建localhost:3000
HttpEntity