How to retrieve network link status from Kernel?

I have need for a reliable and easy way to get from within a script, or a java class, the status of the network interface cards (whether the link is up, or down).
I believe the kernel status would be quicker to know if they were up or down rather than if a ping simply didnt respond back.
My brain lately has been on hold and need some ideas and mabye code sample. Thanks.

This will display the link status for all network interfaces from the kernel:

kstat -c net -s link_up

Try,

dladm show-dev| awk '{print $1,t,$2,t,$3}'

if using Solaris 10.