Java Emoji Check resolveToEmojiFromByte(String str)

Here you can find the source of resolveToEmojiFromByte(String str)

Description

resolve To Emoji From Byte

License

Open Source License

Declaration

public static String resolveToEmojiFromByte(String str) 

Method Source Code


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

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static String resolveToEmojiFromByte(String str) {
        Pattern pattern2 = Pattern.compile("<:([[-]\\d*[,]]+):>");
        Matcher matcher2 = pattern2.matcher(str);
        StringBuffer sb3 = new StringBuffer();
        while (matcher2.find()) {
            matcher2.appendReplacement(sb3, resolveToEmoji(matcher2.group(0)));
        }/*from  w  w w .j  ava 2  s . c  om*/
        matcher2.appendTail(sb3);
        return sb3.toString();
    }

    private static String resolveToEmoji(String str) {
        str = str.replaceAll("<:", "").replaceAll(":>", "");
        String[] s = str.split(",");
        byte[] b = new byte[s.length];
        for (int i = 0; i < s.length; i++) {
            b[i] = Byte.valueOf(s[i]);
        }
        return new String(b);
    }
}

Related

  1. emoji(int hexEmoji)
  2. emoji(String emoji)
  3. filterEmoji(String source)
  4. isEmoji(char c)
  5. resolveToEmoji(String str)