简体   繁体   中英

How to parse ip address from /proc/PID/net/tcp and /proc/PID/net/tcp6 files in Java?

Here are some output from /proc/PID/net/tcp6 file:

  sl  local_address                         remote_address                        st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
   0: 0000000000000000FFFF00000F02000A:BDC7 0000000000000000FFFF00002ACD3AD8:01BB 08 00000000:00000001 00:00000000 00000000 10007        0 130895 1 00000000 29 4 14 10 -1

I would recommend you to use terminal commands in Java like grep , cut , awk . Text and output reading/editing commands will make your job.

While using terminal commands consecutively you should use | (pipe) between commands. Command on the right side of the pipe will affect the left side of pipe's output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM