Convert to byte array
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MainClass {
public static byte[] makeBytes(long t, double q) {
try {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(byteOut);
dataOut.writeLong(t);
dataOut.writeDouble(q);
return byteOut.toByteArray();
} catch (IOException e) {
return new byte[0];
}
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
IO ByteArrayInputStream:
- Create ByteArrayInputStream from a String
- Create UTF8 InputStream
- Convert to byte array