Java ByteBuffer to Short toShort(ByteBuffer value)

Here you can find the source of toShort(ByteBuffer value)

Description

to Short

License

Open Source License

Declaration

public static short toShort(ByteBuffer value) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    public static short toShort(ByteBuffer value) {
        short result = 0;
        try {//  w  ww  .ja  va2 s  .c  om
            if (value != null) {
                int originPos = value.position();
                result = value.getShort();
                value.position(originPos);
            }
        } catch (Exception ex) {
            // ex.printStackTrace();
        }
        return result;
    }
}

Related

  1. toShort(ByteBuffer buffer)
  2. toShort(ByteBuffer bytes)