Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Read arp cache?

  1. #1
    orestis125 is offline Member
    Join Date
    Jun 2012
    Rep Power

    Default 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:

    Java Code:
        public static String getARPCache() {
            String cmd = "arp -a";
            Runtime run = Runtime.getRuntime();
            String result = "ARP Cache: ";
            try {
                Process proc = run.exec(cmd);
                BufferedReader buf = new BufferedReader(new InputStreamReader(proc.getInputStream()));
                String line;
                while ((line = buf.readLine()) != null) {
                    result += line + "\n";
            } catch (IOException | InterruptedException ex) {
            return (result);
    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?

    Thank you very much,
    I appreciate your help

    Last edited by orestis125; 09-28-2012 at 03:27 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default 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().

    orestis125 likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    orestis125 is offline Member
    Join Date
    Jun 2012
    Rep Power

    Default Re: Read arp cache?

    Oh silly me. Thank you very much it works perfectly now.

    I appreciate your help

Similar Threads

  1. Binary Cache
    By Collider in forum New To Java
    Replies: 10
    Last Post: 05-03-2012, 04:22 PM
  2. Configration or Cache (JCS)
    By yatin110 in forum New To Java
    Replies: 0
    Last Post: 06-24-2010, 11:06 AM
  3. Cache Objects
    By jonnytabpni in forum New To Java
    Replies: 2
    Last Post: 12-24-2009, 09:30 AM
  4. creating cache
    By Omarero in forum New To Java
    Replies: 1
    Last Post: 02-01-2009, 07:31 PM
  5. cache problem in jsp
    By lpwing in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 01-15-2008, 07:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts