Tabnine Logo
ByteArrayDataOutputStream.write
Code IndexAdd Tabnine to your IDE (free)

How to use
write
method
in
org.jgroups.util.ByteArrayDataOutputStream

Best Java code snippets using org.jgroups.util.ByteArrayDataOutputStream.write (Showing top 20 results out of 315)

origin: wildfly/wildfly

public void writeInt(int v) {
  write((v >>> 24) & 0xFF);
  write((v >>> 16) & 0xFF);
  write((v >>>  8) & 0xFF);
  write((v >>>  0) & 0xFF);
}
origin: wildfly/wildfly

write(bytearr, 0, utflen+2);
origin: wildfly/wildfly

out.write(TYPE_UTF_STRING);
out.writeUTF(str);
byte[] ret=new byte[out.position()];
origin: wildfly/wildfly

public void write(byte b[], int off, int len) throws IOException {
  output.write(b, off, len);
}
origin: wildfly/wildfly

protected void sendLocalAddress(Address local_addr) throws Exception {
  try {
    int addr_size=local_addr.serializedSize();
    int expected_size=cookie.length + Global.SHORT_SIZE*2 + addr_size;
    ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size +2);
    out.write(cookie, 0, cookie.length);
    out.writeShort(Version.version);
    out.writeShort(addr_size); // address size
    local_addr.writeTo(out);
    ByteBuffer buf=out.getByteBuffer();
    send(buf, false);
    updateLastAccessed();
  }
  catch(Exception ex) {
    close();
    throw ex;
  }
}
origin: wildfly/wildfly

public void writeChar(int v) {
  write((v >>> 8) & 0xFF);
  write((v >>> 0) & 0xFF);
}
origin: wildfly/wildfly

public void writeLong(long v) {
  write((byte)(v >>> 56));
  write((byte)(v >>> 48));
  write((byte)(v >>> 40));
  write((byte)(v >>> 32));
  write((byte)(v >>> 24));
  write((byte)(v >>> 16));
  write((byte)(v >>>  8));
  write((byte)(v >>>  0));
}
origin: wildfly/wildfly

public void write(int b) throws IOException {
  output.write(b);
}
origin: wildfly/wildfly

public void writeShort(int v) {
  write((v >>> 8) & 0xFF);
  write((v >>> 0) & 0xFF);
}
origin: wildfly/wildfly

public void write(byte b[]) throws IOException {
  output.write(b);
}
origin: wildfly/wildfly

public void write(byte[] b) {
  write(b, 0, b.length);
}
origin: wildfly/wildfly

public void writeBoolean(boolean v) {
  write(v ? 1 : 0);
}
origin: wildfly/wildfly

public void writeByte(int v) {
  write(v);
}
origin: wildfly/wildfly

public void writeBytes(String s) {
  int len=s != null? s.length() : 0;
  if(len > 0)
    ensureCapacity(len);
  for(int i = 0 ; i < len ; i++)
    write((byte)s.charAt(i));
}
origin: wildfly/wildfly

/**
 * Serializes/Streams an object into a byte buffer.
 * The object has to implement interface Serializable or Externalizable or Streamable.
 */
public static byte[] objectToByteBuffer(Object obj) throws Exception {
  if(obj == null)
    return TYPE_NULL_ARRAY;
  if(obj instanceof Streamable) {
    int expected_size=obj instanceof SizeStreamable? ((SizeStreamable)obj).serializedSize() : 512;
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size, true);
    out.write(TYPE_STREAMABLE);
    writeGenericStreamable((Streamable)obj,out);
    return Arrays.copyOf(out.buf,out.position());
  }
  Byte type=PRIMITIVE_TYPES.get(obj.getClass());
  if(type == null) { // will throw an exception if object is not serializable
    final ByteArrayDataOutputStream out_stream=new ByteArrayDataOutputStream(512, true);
    out_stream.write(TYPE_SERIALIZABLE);
    try(ObjectOutputStream out=new ObjectOutputStream(new OutputStreamAdapter(out_stream))) {
      out.writeObject(obj);
      out.flush();
      return Arrays.copyOf(out_stream.buffer(), out_stream.position());
    }
  }
  return marshalPrimitiveType(type, obj);
}
origin: wildfly/wildfly

public static Buffer objectToBuffer(Object obj) throws Exception {
  if(obj == null)
    return new Buffer(TYPE_NULL_ARRAY);
  if(obj instanceof Streamable) {
    int expected_size=obj instanceof SizeStreamable? ((SizeStreamable)obj).serializedSize() : 512;
    final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size, true);
    out.write(TYPE_STREAMABLE);
    writeGenericStreamable((Streamable)obj,out);
    return out.getBuffer();
  }
  Byte type=PRIMITIVE_TYPES.get(obj.getClass());
  if(type == null) { // will throw an exception if object is not serializable
    final ByteArrayDataOutputStream out_stream=new ByteArrayDataOutputStream(512, true);
    out_stream.write(TYPE_SERIALIZABLE);
    try(ObjectOutputStream out=new ObjectOutputStream(new OutputStreamAdapter(out_stream))) {
      out.writeObject(obj);
      out.flush();
      return out_stream.getBuffer();
    }
  }
  return new Buffer(marshalPrimitiveType(type, obj));
}
origin: org.jboss.eap/wildfly-client-all

public void writeLong(long v) {
  write((byte)(v >>> 56));
  write((byte)(v >>> 48));
  write((byte)(v >>> 40));
  write((byte)(v >>> 32));
  write((byte)(v >>> 24));
  write((byte)(v >>> 16));
  write((byte)(v >>>  8));
  write((byte)(v >>>  0));
}
origin: org.jboss.eap/wildfly-client-all

public void writeInt(int v) {
  write((v >>> 24) & 0xFF);
  write((v >>> 16) & 0xFF);
  write((v >>>  8) & 0xFF);
  write((v >>>  0) & 0xFF);
}
origin: org.jboss.eap/wildfly-client-all

public void writeShort(int v) {
  write((v >>> 8) & 0xFF);
  write((v >>> 0) & 0xFF);
}
origin: org.jboss.eap/wildfly-client-all

public void writeChar(int v) {
  write((v >>> 8) & 0xFF);
  write((v >>> 0) & 0xFF);
}
org.jgroups.utilByteArrayDataOutputStreamwrite

Popular methods of ByteArrayDataOutputStream

  • <init>
  • buffer
  • checkBounds
  • ensureCapacity
    Grows the buffer; whether it grow linearly or exponentially depends on grow_exponentially
  • getBuffer
  • getByteBuffer
  • position
  • writeBoolean
  • writeByte
  • writeChar
  • writeInt
  • writeLong
  • writeInt,
  • writeLong,
  • writeShort,
  • writeUTF

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • requestLocationUpdates (LocationManager)
  • String (java.lang)
  • Permission (java.security)
    Legacy security code; do not use.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • JCheckBox (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now