Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String getWriteType(int writeType) {
        StringBuilder permissionStr = new StringBuilder();
        String binaryString = Integer.toBinaryString(writeType);
        binaryString = String.format("%16s", binaryString).replace(' ', '0');
        int len = binaryString.length();
        //WRITE_TYPE_NO_RESPONSE (0x00000001)
        if (binaryString.charAt(len - 1) == '1') {
            permissionStr.append("NO_RESPONSE,");
        }
        //WRITE_TYPE_DEFAULT (0x00000002)
        if (binaryString.charAt(len - 2) == '1') {
            permissionStr.append("WRITE,");
        }
        //WRITE_TYPE_SIGNED (0x00000004)
        if (binaryString.charAt(len - 3) == '1') {
            permissionStr.append("SIGNED,");
        }

        String perStr = permissionStr.toString();
        if (perStr.endsWith(",")) {
            perStr = perStr.substring(0, perStr.length() - 1);
        }

        return perStr;
    }
}