how to get send, receive byte and network bandwidth utilization
Using java.net.Networ开发者_运维问答kInterface
I am getting the status (up/down) of network.
I want to get the value of send and receive byte on the network card. And I need to calculate network utilization also.
How to get these in Java?
I don't think there is a pure Java way of doing this. So one solution is to use JNI and a native library, which of course would have to be OS-specific.
If you want something more portable, I suggest trying out SNMP. All common OS should support querying such data via SNMP (perhaps after installing an SNMP server), and there are also Java SNMP client implementations available.
I would suggest using OSHI. The NetworkIF
class supports everything you need.
精彩评论