Java Byte Array Create toByteArray(Object value)

Here you can find the source of toByteArray(Object value)

Description

to Byte Array

License

Open Source License

Declaration

private static byte[] toByteArray(Object value) 

Method Source Code

//package com.java2s;
/*-------------------------------------------------------------------------------------------------
 _______ __   _ _______ _______ ______  ______
 |_____| | \  |    |    |______ |     \ |_____]
 |     | |  \_|    |    ______| |_____/ |_____]
    //from w w  w  . j a va2s  .c om
 Copyright (c) 2016, antsdb.com and/or its affiliates. All rights reserved. *-xguo0<@
    
 This program is free software: you can redistribute it and/or modify it under the terms of the
 GNU Affero General Public License, version 3, as published by the Free Software Foundation.
    
 You should have received a copy of the GNU Affero General Public License along with this program.
 If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>
-------------------------------------------------------------------------------------------------*/

public class Main {
    private static byte[] toByteArray(Object value) {
        if (value == null) {
            return null;
        } else if (value instanceof byte[]) {
            return (byte[]) value;
        } else {
            throw new IllegalArgumentException();
        }
    }
}

Related

  1. toByteArray(Long mac)
  2. toByteArray(long value)
  3. toByteArray(long value)
  4. toByteArray(Number[] array)
  5. toByteArray(Object obj)
  6. toByteArray(short foo)
  7. toByteArray(String address)
  8. toByteArray(String binString)
  9. toByteArray(String bytesStr, int byteLength)