2010년 03월 18일
자바로 MAC address 구해보기
import java.io.*;public class MacAddressTest {public static void main(String args[]) throws Exception {Process process = Runtime.getRuntime().exec("ipconfig /all");InputStream standardOutput = process.getInputStream(), standardError =process.getErrorStream() ;String output = "";int c;while ((c = standardOutput.read()) != -1) {output = output + new Character((char)c).toString();}while ((c = standardError.read()) != -1)standardOutput.close();standardError.close();BufferedReader br = new BufferedReader(new StringReader(output));String line = null;while ((line = br.readLine()) != null) {if (line.trim().startsWith("Physical Address")) {String mac = line.substring(line.indexOf(":")+1,line.length()).trim();System.out.println("MAC Address : " + mac);}}}}
# by | 2010/03/18 14:22 | ICT 정보와 IoT | 트랙백(1)
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
제목 : 자바 네트워크, InetAddress클래스로 IP ..
import java.net.InetAddress ; import java.net.UnknownHostException ; import java.io.IOException ; public class IPAddressTest { public static void main(String[]&......more