String baseUrl = "http://localhost:9000/file"; File file = new File("E:/girl.jpg"); OkHttpClient okHttpClient = new OkHttpClient(); RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), file); MultipartBody body = new MultipartBody.Builder().setType(MediaType.parse("multipart/form-data")) .addFormDataPart("file", file.getName(), fileBody).build(); Request request = new Request.Builder().post(body).url(baseUrl).build(); long start = new Date().getTime(); okHttpClient.newCall(request).execute().body().string(); long end = new Date().getTime(); System.out.println("use "+(end-start));