Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.Log;

public class Main {
    public static void log(String region, String message) {
        Log.d("Softphone", region + ": " + message + getLocation(2));
    }

    public static String getLocation() {
        return getLocation(2);
    }

    public static String getLocation(int back) {
        try {
            // Use Throwable to obtain stack trace, using Thread.currentThread().getStackTrace is expensive because of thread-safety */
            StackTraceElement e = (new Throwable()).getStackTrace()[back];
            if (e.isNativeMethod()) {
                return " [<native>]";
            }
            return " [" + e.getClassName().split("\\$")[0].replace('.', '/') + ".java:" + e.getLineNumber() + "]";
        } catch (ArrayIndexOutOfBoundsException e) {
        } catch (SecurityException e) {
        }
        return " [<unknown>]";
    }
}