Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;

public class Main {

    public static String getMac() {
        String macAdress = null;
        String str = "";
        try {
            Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address ");
            InputStreamReader ir = new InputStreamReader(pp.getInputStream());
            LineNumberReader input = new LineNumberReader(ir);
            for (; null != str;) {
                str = input.readLine();
                if (str != null) {
                    macAdress = str.trim();
                    break;
                }
            }
            ir.close();
            input.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return macAdress;
    }
}