List of usage examples for java.io DataOutputStream writeLong
public final void writeLong(long v) throws IOException
long
to the underlying output stream as eight bytes, high byte first. From source file:com.enonic.cms.framework.util.UUIDGenerator.java
/** * Generate random uuid.//from w w w. j ava2 s . c o m */ public static String randomUUID() { UUID uuid = UUID.randomUUID(); try { ByteArrayOutputStream out = new ByteArrayOutputStream(); DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeLong(uuid.getMostSignificantBits()); dataOut.writeLong(uuid.getLeastSignificantBits()); dataOut.close(); return new String(Hex.encodeHex(out.toByteArray())); } catch (Exception e) { return uuid.toString(); } }
From source file:Main.java
public static byte[] createAuthenticationDigest(String passcode, long t1, double q1) throws IOException, NoSuchAlgorithmException { ByteArrayOutputStream baos = new ByteArrayOutputStream(512); DataOutputStream out = new DataOutputStream(baos); byte[] digest = createDigest(passcode, t1, q1); out.writeLong(t1); out.writeDouble(q1);/*ww w .j a v a 2 s .c om*/ out.writeInt(digest.length); out.write(digest); out.flush(); return baos.toByteArray(); }
From source file:org.apache.hadoop.hdfs.qjournal.client.TestQuorumJournalManagerManifest.java
public static byte[] getBytes(Long val) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeLong(val); return baos.toByteArray(); }
From source file:org.globus.ftp.dc.EBlockImageDCWriter.java
public static void close(DataOutputStream myOutput) throws IOException { byte desc;//from ww w . j a v a 2 s . c o m // EOF and EOD have already been sent desc = WILL_CLOSE; myOutput.writeByte(desc); myOutput.writeLong(0); myOutput.writeLong(0); logger.debug("Wrote WILL_CLOSE, closing the socket"); // close the socket myOutput.close(); }
From source file:fiftyone.mobile.detection.webapp.JavascriptProvider.java
/** * Returns a base 64 encoded version of the hash for the core JavaScript * being returned./*from w ww . j av a2s.c o m*/ * @param dataSet providing the JavaScript properties. * @param request * @return */ private static String eTagHash(Dataset dataSet, HttpServletRequest request) throws IOException, NoSuchAlgorithmException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); dos.writeLong(dataSet.published.getTime()); dos.writeChars(request.getHeader("User-Agent")); dos.writeChars(request.getQueryString()); return Base64.encodeBase64String(MessageDigest.getInstance("MD5").digest(bos.toByteArray())); }
From source file:org.tranche.server.logs.LogUtil.java
/** * Convert long to bytes and return the byte array representation. * @param value/*from w ww . j a va 2 s . co m*/ * @return * @throws java.lang.Exception */ public static byte[] convertLongToBytes(long value) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeLong(value); dos.flush(); try { return baos.toByteArray(); } finally { dos.close(); } }
From source file:org.apache.flink.runtime.metrics.dump.MetricDumpSerialization.java
private static void serializeCounter(DataOutputStream dos, Counter counter) throws IOException { dos.writeLong(counter.getCount()); }
From source file:org.mobisocial.corral.CorralClient.java
private static String hashToString(long hash) { try {//w w w .ja v a 2 s. c o m ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); dos.writeLong(hash); dos.writeInt(-4); byte[] data = bos.toByteArray(); return FastBase64.encodeToString(data).substring(0, 11); } catch (IOException e) { return null; } }
From source file:com.opensoc.json.serialization.JSONEncoderHelper.java
public static void putNumber(DataOutputStream data, Number value) throws IOException { // TODO Auto-generated method stub data.writeByte(JSONKafkaSerializer.NumberID); if (value instanceof Double) { data.writeByte(0);/*from www . j a va 2 s.c o m*/ data.writeDouble((Double) value); return; } data.writeByte(1); data.writeLong((Long) value); }
From source file:org.apache.flink.runtime.metrics.dump.MetricDumpSerialization.java
private static void serializeHistogram(DataOutputStream dos, Histogram histogram) throws IOException { HistogramStatistics stat = histogram.getStatistics(); dos.writeLong(stat.getMin()); dos.writeLong(stat.getMax());/*from w w w .j av a 2 s . co m*/ dos.writeDouble(stat.getMean()); dos.writeDouble(stat.getQuantile(0.5)); dos.writeDouble(stat.getStdDev()); dos.writeDouble(stat.getQuantile(0.75)); dos.writeDouble(stat.getQuantile(0.90)); dos.writeDouble(stat.getQuantile(0.95)); dos.writeDouble(stat.getQuantile(0.98)); dos.writeDouble(stat.getQuantile(0.99)); dos.writeDouble(stat.getQuantile(0.999)); }