Results 1 to 3 of 3
Thread: Read arp cache?
- 09-28-2012, 01:11 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 13
- Rep Power
- 0
Read arp cache? [Solved]
Heya everyone,
Is there any way to read the ARP cache in java? I can't find any solution for this anywhere. This is what I've tried:
But it seems that it waits for the process to finish forever. Any ideas what might be causing this, or how to get the ARP cache using another approach?Java Code:public static String getARPCache() { String cmd = "arp -a"; Runtime run = Runtime.getRuntime(); String result = "ARP Cache: "; try { Process proc = run.exec(cmd); proc.waitFor(); BufferedReader buf = new BufferedReader(new InputStreamReader(proc.getInputStream())); String line; while ((line = buf.readLine()) != null) { result += line + "\n"; } } catch (IOException | InterruptedException ex) { System.out.println(ex.getMessage()); } return (result); }
Thank you very much,
I appreciate your help
OrestisLast edited by orestis125; 09-28-2012 at 03:27 PM.
- 09-28-2012, 03:22 PM #2
Re: Read arp cache?
Your code is waiting for the process to complete (at line 7) while the process, having filled its buffer, is waiting to write its output.
You don't need a waitFor().
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 09-28-2012, 03:27 PM #3
Member
- Join Date
- Jun 2012
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
Binary Cache
By Collider in forum New To JavaReplies: 10Last Post: 05-03-2012, 04:22 PM -
Configration or Cache (JCS)
By yatin110 in forum New To JavaReplies: 0Last Post: 06-24-2010, 11:06 AM -
Cache Objects
By jonnytabpni in forum New To JavaReplies: 2Last Post: 12-24-2009, 09:30 AM -
creating cache
By Omarero in forum New To JavaReplies: 1Last Post: 02-01-2009, 07:31 PM -
cache problem in jsp
By lpwing in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 01-15-2008, 07:43 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks