bytes To Word - Java java.lang

Java examples for java.lang:byte Array

Description

bytes To Word

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte[] bytes = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        int off = 2;
        System.out.println(bytesToWord(bytes, off));
    }// ww w .ja va2  s  .  c o  m

    public static int bytesToWord(byte[] bytes, int off) {
        return (bytes[(off + 1)] & 0xFF) << 8 | bytes[off] & 0xFF;
    }
}

Related Tutorials