Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.Log;
import java.io.*;

public class Main {
    private static final String TAG = "Utils";

    public static String readDeviceUUID(String devicePath) {
        String uuid = null;
        File root = new File(devicePath);
        if (root.isDirectory()) {
            File uFile = new File(devicePath, ".uuid");
            FileReader reader = null;
            try {
                char[] buffer = new char[36];
                reader = new FileReader(uFile);
                reader.read(buffer, 0, buffer.length);
                uuid = new String(buffer);
                Log.d(TAG, "readDeviceUUID uuid:" + uuid);
                return uuid;
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return uuid;
    }
}