List of usage examples for java.lang Long BYTES
int BYTES
To view the source code for java.lang Long BYTES.
Click Source Link
From source file:io.datenwelt.cargo.rest.utils.Strings.java
public static String token() { ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES * 100); for (int i = 0; i < 100; i++) { buffer.putLong(random.nextLong()); }//ww w .ja v a2s .c o m return DigestUtils.md5Hex(buffer.array()); }
From source file:io.pravega.controller.store.stream.tables.IndexRecord.java
private static IndexRecord parse(final byte[] bytes, int offset) { final long eventTime = BitConverter.readLong(bytes, offset); final int historyOffset = BitConverter.readInt(bytes, offset + Long.BYTES); return new IndexRecord(eventTime, historyOffset); }
From source file:org.apache.james.mailbox.backup.LongExtraField.java
@Override public ZipShort getLocalFileDataLength() { return new ZipShort(Long.BYTES); }
From source file:org.apache.james.mailbox.backup.LongExtraField.java
@Override public byte[] getLocalFileDataData() { long value = this.value.orElseThrow(() -> new RuntimeException("Value must by initialized")); return ByteBuffer.allocate(Long.BYTES).order(ByteOrder.LITTLE_ENDIAN).putLong(value).array(); }
From source file:org.apache.james.mailbox.backup.LongExtraField.java
@Override public void parseFromLocalFileData(byte[] buffer, int offset, int length) throws ZipException { if (length != Long.BYTES) { throw new ZipException( "Unexpected data length for ExtraField. Expected " + Long.BYTES + " but got " + length + "."); }//from w w w . jav a2 s.c o m value = Optional.of(ByteBuffer.wrap(buffer, offset, Long.BYTES).order(ByteOrder.LITTLE_ENDIAN).getLong()); }
From source file:com.px100systems.util.serialization.DataStream.java
public void writeLong(Long data) { try {/*from w w w .ja v a2 s . com*/ if (data == null) dos.writeInt(NULL); else { dos.writeInt(Long.BYTES); dos.writeLong(data); } } catch (IOException e) { throw new RuntimeException(e); } }
From source file:nl.salp.warcraft4j.util.DataTypeUtil.java
/** * Create a fixed-size 64-bit (8 byte) byte[] from an int value using a byte order. * * @param value The value./*from w w w . j a v a 2 s . c om*/ * @param byteOrder The byte order, using {@code ByteOrder#BIG_ENDIAN} when the byte order is {@code null}. * * @return The byte[]. */ public static byte[] toByteArray(long value, ByteOrder byteOrder) { byte[] longArray = new byte[Long.BYTES]; ByteBuffer.wrap(longArray).order(Optional.ofNullable(byteOrder).orElse(ByteOrder.BIG_ENDIAN)) .putLong(value); return longArray; }
From source file:org.onlab.util.ImmutableByteSequence.java
/** * Creates a new byte sequence of 8 bytes containing the given long value. * * @param original a long value//from w w w .j a va 2 s.co m * @return a new immutable byte sequence */ public static ImmutableByteSequence copyFrom(long original) { return new ImmutableByteSequence(ByteBuffer.allocate(Long.BYTES).putLong(original)); }
From source file:de.micromata.genome.logging.spi.ifiles.IndexHeader.java
public void writeFileHeader(OutputStream os, File indexFile, IndexDirectory indexDirectory) throws IOException { indexDirectoryIdx = indexDirectory.createNewLogIdxFile(indexFile); ByteBuffer lbb = ByteBuffer.wrap(new byte[Long.BYTES]); ByteBuffer ibb = ByteBuffer.wrap(new byte[Integer.BYTES]); os.write(INDEX_FILE_TYPE);//from w ww .j a v a 2 s . c o m os.write(INDEX_FILE_VERSION); lbb.putLong(0, System.currentTimeMillis()); os.write(lbb.array()); ibb.putInt(0, indexDirectoryIdx); os.write(ibb.array()); ByteArrayOutputStream bout = new ByteArrayOutputStream(); for (Pair<String, Integer> headerp : headerOrder) { String hn = StringUtils.rightPad(headerp.getFirst(), HEADER_NAME_LENGTH); bout.write(hn.getBytes()); ibb.putInt(0, headerp.getSecond()); bout.write(ibb.array()); } byte[] headerar = bout.toByteArray(); int idxOffset = FILE_TYPE_LENGTH + FILE_VERSION_LENGTH + Long.BYTES /* timestamp */ + Integer.BYTES /** indexDirectory */ + Integer.BYTES /* indexOfset */ + headerar.length; ibb.putInt(0, idxOffset); os.write(ibb.array()); os.write(headerar); os.flush(); }
From source file:io.pravega.controller.store.stream.tables.IndexRecord.java
public byte[] toByteArray() { byte[] b = new byte[INDEX_RECORD_SIZE]; BitConverter.writeLong(b, 0, eventTime); BitConverter.writeInt(b, Long.BYTES, historyOffset); return b;//www . ja va2s . c o m }