Java Byte Convert From booleanAsByte(boolean val)

Here you can find the source of booleanAsByte(boolean val)

Description

boolean As Byte

License

Mozilla Public License

Declaration

@Nonnull
    public static byte[] booleanAsByte(boolean val) 

Method Source Code

//package com.java2s;
/*****************************************************************************************
 * *** BEGIN LICENSE BLOCK *****//from   w w  w  .  j a  v a 2 s  . c  om
 *
 * Version: MPL 2.0
 *
 * echocat jConscius, Copyright (c) 2010-2012 echocat
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * *** END LICENSE BLOCK *****
 ****************************************************************************************/

import javax.annotation.Nonnull;

public class Main {
    @Nonnull
    public static byte[] booleanAsByte(boolean val) {
        return new byte[] { val ? (byte) 1 : (byte) 0 };
    }
}

Related

  1. asByte(Byte number)
  2. asByte(final Object o)
  3. asByte(Object o)
  4. bytesFrom(String hwAddress)
  5. bytesFromDpid(long dpid)
  6. bytesFromHex(String s)
  7. bytesFromHexString(String values)