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 

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;

public class Main {
    static public String getString(ByteBuffer data) {
        int size = data.get();
        if (size == 0) {
            return "";
        } else {
            byte[] bb = new byte[size * 2 - 2];
            data.get(bb);
            data.getShort();
            try {
                return new String(bb, "UTF-16LE");
            } catch (UnsupportedEncodingException e) {
                return "";
            }
        }
    }
}