All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.plugins.providers.sse.EventByteArrayOutputStream Maven / Gradle / Ivy

The newest version!
package org.jboss.resteasy.plugins.providers.sse;

import java.io.ByteArrayOutputStream;
import java.util.Arrays;

public class EventByteArrayOutputStream extends ByteArrayOutputStream
{
   public synchronized byte[] getEventPayLoad()
   {
      // delimiter is \r or \n
      if (count >= 2 && this.buf[count - 2] == this.buf[count - 1])
      {
         return Arrays.copyOf(buf, count - 1);
      }
      //delimiter is \r\n
      if (count >= 2 && buf[count - 2] == '\r' && buf[count - 1] == '\n')
      {
         return Arrays.copyOf(buf, count - 2);
      }
      return Arrays.copyOf(buf, count);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy