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.Set;

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

    /**
     * set convert to byte[]
     */
    public static byte[] setConvertToByte(Set<String> values, String separate) {
        if (values == null) {
            return null;
        }
        if (values.isEmpty()) {
            return new byte[0];
        }
        String sp = TextUtils.isEmpty(separate) ? COMMA : separate;
        StringBuilder sb = new StringBuilder(64);
        int _size = values.size() - 1;
        int count = 0;
        for (String value : values) {
            sb.append(value);
            if (count != _size) {
                sb.append(sp);
            }
            count++;
        }
        return sb.toString().getBytes();
    }
}