Java – streaming data using httpurlconnection

I want to use httpurlconnection to open a long-term connection with the server through HTTP post and process the stream data when entering This applies to Android projects

I don't know how to do this with httpurlconnection In IOS, nsurlconnection provides an asynchronous mode. When new data enters and can be used for parsing, it will call the callback implemented by the user

Using httpurlconnection in Java, I see an available () method that returns the number of bytes that can be read However, I don't know how to write an open connected streaming application and react when new stream data is available to parse datainputstream

I would appreciate some advice Does httpurlconnection or alternative classes in Java support non blocking and asynchronous processing of HTTP connections?

thank you

Solution

After more research, I have confirmed that Java does not have any built-in asynchronous HTTP support A package called jetty contains an HTTP client with built - in asynchronous HTTP and callback Available at

http://wiki.eclipse.org/Jetty/Tutorial/HttpClient

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>