Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. BufferedReader br = null;
  2. ArrayList<ClientScanResultSO> result = null;
  3.  
  4. try {
  5. result = new ArrayList<ClientScanResultSO>();
  6. br = new BufferedReader(new FileReader("/proc/net/arp"));
  7. String line;
  8. while ((line = br.readLine()) != null) {
  9. String[] splitted = line.split(" +");
  10.  
  11. if ((splitted != null) && (splitted.length >= 4)) {
  12. // Basic sanity check
  13. String mac = splitted[3];
  14. System.out.println("mac is***************"+ mac);
  15. if (mac.matches("..:..:..:..:..:..")) {
  16. boolean isReachable = InetAddress.getByName(splitted[0]).isReachable(reachableTimeout);
  17. String name = InetAddress.getByName(splitted[0]).getHostName();
  18. if (!onlyReachables || isReachable) {
  19. result.add(new ClientScanResultSO(splitted[0], splitted[3], splitted[5], isReachable, name));
  20. }
  21. }
  22. }
  23. }
  24. } catch (Exception e) {
  25. Log.e(this.getClass().toString(), e.getMessage());
  26. } finally {
  27. try {
  28. br.close();
  29. } catch (IOException e) {
  30. Log.e(this.getClass().toString(), e.getMessage());
  31. }
  32. }
  33.  
  34. return result;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement