Moves all bytes one up, meaning the left most byte (0) is swapped to the end - Android java.lang

Android examples for java.lang:Array Element

Description

Moves all bytes one up, meaning the left most byte (0) is swapped to the end

Demo Code


//package com.java2s;

public class Main {
    /**/*from  ww w. j  av a  2  s .  c  om*/
     * Moves all bytes one up, meaning the left most byte (0) is swapped to the end
     */
    public static byte[] rotateLeft(byte[] input) {
        byte[] cycled = new byte[input.length];
        System.arraycopy(input, 1, cycled, 0, input.length - 1);
        cycled[cycled.length - 1] = input[0];
        return cycled;
    }
}

Related Tutorials