public static byte[] rightAlignBytes(byte[] bytes, int width) {
        if (bytes.length != width) {
            byte[] rVal = new byte[width];
            for (int x = width - bytes.length; x < width; x++) {
                rVal[x] = bytes[x - (width - bytes.length)];
            }
            return rVal;
        }
            
        return bytes;
    }
Properly reads in data from the given stream until the specified number
of bytes have been read.

@param store
           the byte array to store in. Array length must be greater than bytes param.
@param bytes
           the number of bytes to read.
@param is
           the stream to read from
@return the store array for chaining purposes
@throws IOException
            if an error occurs while reading from the stream
@throws ArrayIndexOutOfBoundsException
            if bytes greater than the length of the store.
jme3-core/src/plugins/java/com/jme3/export/binary/ByteUtils.java