Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.text.TextUtils;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static final String COMMA = ",";

    /**
     * byte[] convert to set
     */
    public static Set<String> byteConvertToSet(byte[] blob, String separate) {
        if (blob == null) {
            return null;
        }
        if (blob.length == 0) {
            return Collections.EMPTY_SET;
        }
        String sp = TextUtils.isEmpty(separate) ? COMMA : separate;
        String values = new String(blob);
        String[] sV = values.split(sp);
        Set<String> set = new HashSet<>();
        for (String v : sV) {
            set.add(v);
        }
        return set;
    }
}