Java Byte Array Create newByteArray(int size)

Here you can find the source of newByteArray(int size)

Description

Generates a byte[] the is filled with a repeated sequence of 0x00 to 0xFF.

License

Apache License

Declaration

private static byte[] newByteArray(int size) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    /**//from   w  ww  .j  a  v  a  2 s. c o m
     *  Generates a <code>byte[]</code> the is filled with a repeated sequence
     *  of 0x00 to 0xFF. This is typically used as a "background" array for
     *  tests.
     */
    private static byte[] newByteArray(int size) {
        byte[] data = new byte[size];
        for (int ii = 0; ii < data.length; ii++)
            data[ii] = (byte) (ii % 256);
        return data;
    }
}

Related

  1. bytes(final int... ints)
  2. bytes(int... bytes)
  3. bytes(int... ints)
  4. newByteArray(byte[] data, int finalSize)
  5. newByteArray(int len)
  6. newByteArray(int... bytes)
  7. newByteArray(int... bytes)
  8. toByte(char[] bytes, boolean le)
  9. toByteArr(final float value, final boolean lsbIsFirst)