The method returns a byte[] of the given size. - Java java.lang

Java examples for java.lang:byte Array

Description

The method returns a byte[] of the given size.

Demo Code

/**/*ww w  . j av  a 2s .co  m*/
 * Copyright (c) 2010-2014, openHAB.org and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int size = 2;
        System.out.println(java.util.Arrays.toString(getByteArray(size)));
    }

    /**
     * The method returns a byte[] of the given size. 
     * @param size of the resulting byte[]
     * @return
     */
    public static byte[] getByteArray(int size) {
        return new byte[size];
    }
}

Related Tutorials