Salve a tutti,
avrei bisogno di reperire alcune informazioni sulla scheda di rete.
Ho trovato questo codice:
questo codice funziona. Però nel momento in cui spego il wireless non mi viene restituito nessun codice....codice:import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; import java.util.Enumeration; public class MacAddress { public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost(); //InetAddress address = InetAddress.getByName("192.168.2.2"); /* * Get NetworkInterface for the current host and then read the * hardware address. */ NetworkInterface ni = NetworkInterface.getByInetAddress(address); if (ni != null) { byte[] mac = ni.getHardwareAddress(); if (mac != null) { /* * Extract each array of mac address and convert it to hexa with the * following format 08-00-27-DC-4A-9E. */ for (int i = 0; i < mac.length; i++) { System.out.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""); } } else { System.out.println("Address doesn't exist or is not accessible."); } } else { System.out.println("Network Interface for the specified address is not found."); } } catch (UnknownHostException e) { e.printStackTrace(); } catch (SocketException e) { e.printStackTrace(); } } }
c'è qualcosa che posso fare per prelevare lo stesso l'indirizzo mac di una scheda di rete da un PC
oppure un altro modo per prelevare un seriale su un pc^???



Rispondi quotando