which method is better for network communication using java.net or java.nio for Android applications

95 views Asked by At

I wanted to test which method I should use for performing network communication for my Android app. I want fastest network communication.

How should I test these two methods java.net and java.nio for my mobile app to get to the conclusion.

Any pointers ?

2

There are 2 answers

2
user207421 On

Unless you're writing a server that expects to have tens of thousands of incoming connections there is no reason to prefer java.nio over java.net, and the latter is very much simpler to program.

I did very extensive benchmark testing with 1700 data points some years ago, which inter alia proved there was no performance difference between java.net and java.nio over single Internet connections.

2
mahip_j On

java.net method is better for network communication using java.net or java.nio for Android applications