What exactly returns EntityUtils.toString(response)?

前端 未结 2 2031
南旧
南旧 2021-01-06 17:35

I\'m doing my API REST and I saw that in a lot of examples people use EntityUtils.toString(response) to get their response into a String

2条回答
  •  感情败类
    2021-01-06 18:05

    An HttpEntity represents the content of the body of an HTTP response. EntityUtils.toString(HttpEntity) interprets that content as a String and returns it to you.

    If your HTTP response is something like this

    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: 80
    
    
    
        
    
    

    Then the String returned by EntityUtils.toString(HttpEntity) will simply contain

    
    
        
    
    

提交回复
热议问题