List of usage examples for com.google.common.primitives Bytes toArray
public static byte[] toArray(Collection<? extends Number> collection)
From source file:org.jclouds.googlecloudstorage.domain.DomainUtils.java
public static byte[] reverse(byte[] b) { List<Byte> hashByte = Bytes.asList(b); List<Byte> reversedList = Lists.reverse(hashByte); return Bytes.toArray(reversedList); }
From source file:io.v.impl.google.lib.discovery.UUIDUtil.java
/** * Converts from {@link Uuid} to {@link UUID} *///from w w w . ja va 2 s. c om public static UUID UuidToUUID(Uuid id) { ByteBuffer b = ByteBuffer.wrap(Bytes.toArray(id)); return new UUID(b.getLong(), b.getLong()); }
From source file:org.apache.brooklyn.util.math.BitUtils.java
/** as {@link #reverseBitSignificance(byte...)}, but taking ints for convenience (ignoring high bits) */ public static byte[] reverseBitSignificanceInBytes(int... bytes) { return reverseBitSignificance(Bytes.toArray(Ints.asList(bytes))); }
From source file:c1c.v8fs.jaxb.DataArrayAdapter.java
@Override public byte[] unmarshal(DataArrayAdapter.DataAttayAdaptedList v) throws Exception { final List<Byte> lst = Lists.newArrayList(); v.entities.stream().forEach((itm) -> { for (byte b : itm.row) { lst.add(b);// w w w . j a v a2 s .c om } }); return Bytes.toArray(lst); }
From source file:se.sics.datamodel.util.ByteId.java
ByteId(Collection<Byte> id) {
this.id = Bytes.toArray(id);
}
From source file:net.larry1123.elec.util.config.fieldhanders.bytes.ByteArrayListFieldHandler.java
/** * {@inheritDoc}//from w w w .j a v a 2s . c o m */ @Override public void setToFile(ArrayList<Byte> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setByteArray(getPropertyKey(), Bytes.toArray(value), getSpacer()); } }
From source file:io.v.android.apps.account_manager.ReceiveBluetoothMessage.java
@Override protected byte[] doInBackground(Void... args) { if (mError != null) { return null; }//from ww w. ja v a 2 s . c om Looper.prepare(); ArrayList<Byte> message = new ArrayList<Byte>(); byte lastByte; try { while (true) { lastByte = (byte) mInStream.read(); if (lastByte != SendBluetoothMessage.END_OF_MESSAGE) { message.add(lastByte); } else { break; } } return Bytes.toArray(message); } catch (IOException e) { mError = e.getMessage(); return null; } }
From source file:org.terasology.persistence.typeHandling.coreTypes.ByteTypeHandler.java
@Override public PersistedData serializeCollection(Collection<Byte> value, SerializationContext context) { return context.create(Bytes.toArray(value)); }
From source file:com.itude.mobile.mobbl.core.util.ByteUtil.java
static public byte[] encodeBytes(byte[] bytes, String encodingType) { byte[] result = null; //According to the information on Microsoft's and the Unicode Consortium's websites, positions 81, 8D, 8F, 90, and 9D are unused if (encodingType.equals("windows-1252")) { List<Byte> stripped = new ArrayList<Byte>(bytes.length); for (byte b : bytes) { if (b == (byte) 0x81) { stripped.add((byte) -62); stripped.add((byte) -127); } else if (b == (byte) 0x8D) { stripped.add((byte) -62); stripped.add((byte) -115); } else if (b == (byte) 0x8F) { stripped.add((byte) -62); stripped.add((byte) -113); } else if (b == (byte) 0x90) { stripped.add((byte) -62); stripped.add((byte) -112); } else if (b == (byte) 0x9D) { stripped.add((byte) -62); stripped.add((byte) -99); } else { String resultString = encodeBytesToString(new byte[] { b }, encodingType); byte[] encodedBytes = null; try { encodedBytes = resultString.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { LOG.warn("unable is encode bytes with type " + encodingType); encodedBytes = resultString.getBytes(); }/*from w w w . j a va 2 s. com*/ for (byte stringbyte : encodedBytes) { stripped.add(stringbyte); } } } result = Bytes.toArray(stripped); } else { String resultString = encodeBytesToString(bytes, encodingType); // try { result = resultString.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { LOG.warn("unable is encode bytes with type " + encodingType); result = resultString.getBytes(); } } return result; }
From source file:org.onosproject.ospf.protocol.lsa.TlvHeader.java
/** * Gets TLV header as bytes.// w w w. j a v a 2s . c o m * * @return TLV header as bytes */ public byte[] getTlvHeaderAsByteArray() { List<Byte> headerLst = new ArrayList(); headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.tlvType))); headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.tlvLength))); return Bytes.toArray(headerLst); }