Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    private static String unescape(String str) {
        StringBuilder sb = new StringBuilder();
        String[] codeStrs = str.split("\\\\u");
        for (String codeStr : codeStrs) {
            if (codeStr.isEmpty()) {
                continue;
            }
            try {
                if (codeStr.length() <= 4) {
                    sb.append(Character.valueOf((char) Integer.parseInt(codeStr, 16)));
                } else {
                    sb.append(Character.valueOf((char) Integer.parseInt(codeStr.substring(0, 4), 16)));
                    sb.append(codeStr.substring(4));
                }
            } catch (NumberFormatException e) {
                sb.append(codeStr);
            }
        }
        return sb.toString();
    }
}