Java UTF-8 encoding not working HttpURLConnection

后端 未结 3 775
无人及你
无人及你 2021-01-03 23:30

I tried to do post call and to pass input with this value - \"ä€愛لآहที่\" I got error message

{\"error\":{\"code\":\"\",\"message\":{\"lang\":\"en-US\",\"va         


        
3条回答
  •  無奈伤痛
    2021-01-04 00:07

    You have to send content via byte array

     DataOutputStream outputStream= new DataOutputStream(conn.getOutputStream());
     outputStream.write(content.toString().getBytes());
    

    This is completely solution for your file name character problems. The imported point is string sending via byte array. Every character changing via byte character. This is prevent your character encoding problems.

提交回复
热议问题