/* (non-Javadoc)
@see tuwien.auto.calimero.knxnetip.util.DIB#toByteArray()
486527
public byte[] toByteArray()
	{
		final byte[] buf = super.toByteArray();
		int i = 2;
		buf[i++] = (byte) knxmedium;
		buf[i++] = (byte) devicestatus;
		final byte[] addr = address.toByteArray();
		buf[i++] = addr[0];
		buf[i++] = addr[1];
		buf[i++] = (byte) (projectInstallID >> 8);
		buf[i++] = (byte) projectInstallID;
		for (int k = 0; k < 6; ++k)
			buf[i++] = serial[k];
		for (int k = 0; k < 4; ++k)
			buf[i++] = mcaddress[k];
		for (int k = 0; k < 6; ++k)
			buf[i++] = mac[k];
		for (int k = 0; k < name.length(); ++k)
			buf[i++] = (byte) name.charAt(k);
		return buf;
	}
1360816
public byte[] toBytes() throws IOException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ZipOutputStream stream = new ZipOutputStream(bout);
        ZipEntry ze = new ZipEntry("async_message");
        stream.putNextEntry(ze);
        stream.write(toXml().getBytes());
        stream.flush();
        stream.close();
        return  bout.toByteArray();
    }
50768
public byte[] toByteArray() {
        final ByteBuffer buff = ByteBuffer.allocate(getSize());

        // add revision
        buff.put(revision);

        // add reserved
        buff.put((byte) 0x00);

        // add contro flags
        buff.put(controlFlags[1]);
        buff.put(controlFlags[0]);

        // add offset owner
        buff.position(4);

        int nextAvailablePosition = 20;
        // add owner SID
        if (owner == null) {
            buff.putInt(0);
        } else {
            buff.put(Hex.reverse(NumberFacility.getBytes(nextAvailablePosition)));
            buff.position(nextAvailablePosition);
            buff.put(owner.toByteArray());
            nextAvailablePosition += owner.getSize();
        }

        // add offset group
        buff.position(8);

        // add group SID
        if (group == null) {
            buff.putInt(0);
        } else {
            buff.put(Hex.reverse(NumberFacility.getBytes(nextAvailablePosition)));
            buff.position(nextAvailablePosition);
            buff.put(group.toByteArray());
            nextAvailablePosition += group.getSize();
        }

        // add offset sacl
        buff.position(12);

        // add SACL
        if (sacl == null) {
            buff.putInt(0);
        } else {
            buff.put(Hex.reverse(NumberFacility.getBytes(nextAvailablePosition)));
            buff.position(nextAvailablePosition);
            buff.put(sacl.toByteArray());
            nextAvailablePosition += sacl.getSize();
        }

        // add offset dacl
        buff.position(16);

        // add DACL
        if (dacl == null) {
            buff.putInt(0);
        } else {
            buff.put(Hex.reverse(NumberFacility.getBytes(nextAvailablePosition)));
            buff.position(nextAvailablePosition);
            buff.put(dacl.toByteArray());
        }

        return buff.array();
    }
325977
public byte[] toBytes(@Nullable Object val)
  {
    if (val != null) {
      byte[] bytes = getObjectStrategy().toBytes(val);
      return bytes != null ? bytes : ByteArrays.EMPTY_ARRAY;
    } else {
      return ByteArrays.EMPTY_ARRAY;
    }
  }
222888
public static byte[] toByteArray(File file) {
        FileInputStream is = null;
        try {
            is = new FileInputStream(file);
            return toByteArray(is);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            closeQuietly(is);
        }
    }
423448
private static byte[] toByteArray(InputStream is) throws IOException {
    try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
      byte[] buffer = new byte[0x2000];
      for (int len; (len = is.read(buffer)) != -1; )
        os.write(buffer, 0, len);
      return os.toByteArray();
    }
  }
964216
public byte[] toByteArray()
    {
        byte[] b = new byte[size()];
        unsafe.copyMemory(base, address, b, ARRAY_BYTE_BASE_OFFSET, size());
        return b;
    }
656423
def ToByteArray(self):
        
        ms = StreamManager.GetStream()
        writer = BinaryWriter(ms)
        self.Serialize(writer)

        retval = ms.ToArray()
        StreamManager.ReleaseStream(ms)

        return retval
1318190
public byte[] toByteArray() {
    byte[] copy = new byte[size];
    for (int i = 0; i < size; i++) {
      copy[i] = elements[i];
    }
    return copy;
  }
627543
public byte[] toByteArray() {
    final int preLongs, outBytes;
    final boolean empty = itemsSeen_ == 0;
    final int numItems = (int) Math.min(reservoirSize_, itemsSeen_);

    if (empty) {
      preLongs = 1;
      outBytes = 8;
    } else {
      preLongs = Family.RESERVOIR.getMaxPreLongs();
      outBytes = (preLongs + numItems) << 3; // for longs, we know the size
    }
    final byte[] outArr = new byte[outBytes];
    final WritableMemory mem = WritableMemory.wrap(outArr);

    // build first preLong
    PreambleUtil.insertPreLongs(mem, preLongs);                 // Byte 0
    PreambleUtil.insertLgResizeFactor(mem, rf_.lg());
    PreambleUtil.insertSerVer(mem, SER_VER);                    // Byte 1
    PreambleUtil.insertFamilyID(mem, Family.RESERVOIR.getID()); // Byte 2
    if (empty) {
      PreambleUtil.insertFlags(mem, EMPTY_FLAG_MASK);           // Byte 3
    } else {
      PreambleUtil.insertFlags(mem, 0);
    }
    PreambleUtil.insertK(mem, reservoirSize_);                  // Bytes 4-7

    if (!empty) {
      // second preLong, only if non-empty
      PreambleUtil.insertN(mem, itemsSeen_);

      // insert the serialized samples, offset by the preamble size
      final int preBytes = preLongs << 3;
      mem.putLongArray(preBytes, data_, 0, numItems);
    }

    return outArr;
  }
600502
public byte[] toByteArray() {
		byte[] raw = new byte[8];
		byte[] bi = bigIntValue().toByteArray();
		System.arraycopy(bi, 0, raw, raw.length - bi.length, bi.length);
		return raw;
	}
412072
public byte[] toBytes() throws IOException {
    final ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
    final BitOutputStream out = new BitOutputStream(outBuffer);
    this.write(out);
    out.flush();
    return outBuffer.toByteArray();
  }
1232169
public static byte[] toBytes(int value) {
		final byte[] result = new byte[4];

		result[0] = (byte) (value >> 24);
		result[1] = (byte) (value >> 16);
		result[2] = (byte) (value >> 8);
		result[3] = (byte) (value /* >> 0 */);

		return result;
	}
787755
@Override
	public ByteArray encodeAsByteArray() throws IOException {
		final int size = messages.size();
		if(size == 0) return ByteArray.EMPTY_BYTE_ARRAY;

		AoByteArrayOutputStream bout = new AoByteArrayOutputStream();
		try {
			try (DataOutputStream out = new DataOutputStream(bout)) {
				out.writeInt(size);
				int count = 0;
				for(Message message : messages) {
					count++;
					ByteArray byteArray = message.encodeAsByteArray();
					final int capacity = byteArray.size;
					out.writeByte(message.getMessageType().getTypeByte());
					out.writeInt(capacity);
					out.write(byteArray.array, 0, capacity);
				}
				if(count != size) throw new ConcurrentModificationException();
			}
		} finally {
			bout.close();
		}
		return new ByteArray(bout.getInternalByteArray(), bout.size());
	}
649022
@Override
    public byte[] toBytes(Object object)
    {
        if (object == null)
        {
            return null;
        }
        BigInteger b = (BigInteger) object;
        return b.toByteArray();
    }
269456
public byte[] toByteArray() {
        final byte[] b = new byte[this.len];
        if (this.len > 0) {
            System.arraycopy(this.array, 0, b, 0, this.len);
        }
        return b;
    }
293413
public static byte[] toByteArray( Serializable object )
	{
	    try
	    {
            ByteArrayOutputStream buf = new ByteArrayOutputStream(1024);
            ObjectOutputStream objOut = new ObjectOutputStream(buf);
            objOut.writeObject(object);
            objOut.close();
            return buf.toByteArray();
	    }
	    catch (IOException e)
	    {
	        throw new IllegalArgumentException("Cannot serialize object : "+e.toString());
	    }
	}