Exemple #1
0
 private void DeleteUpThrough(int location)
 {
     // int start = location + 1;  // start at the first byte after the location
     byte[] newBuffer = Arrays.CopyOfRange(buffer.ToByteArray(), location, buffer.Length
                                               ());
     buffer.Clear();
     buffer.Append(newBuffer, 0, newBuffer.Length);
 }
Exemple #2
0
 public virtual void AppendData(byte[] data)
 {
     if (multipartReader != null)
     {
         multipartReader.AppendData(data);
     }
     else
     {
         jsonBuffer.Append(data, 0, data.Length);
     }
 }
 private static ByteArrayBuffer Encode(Encoding charset, string @string)
 {
     ByteBuffer encoded = charset.Encode(CharBuffer.Wrap(@string));
     ByteArrayBuffer bab = new ByteArrayBuffer(encoded.Remaining());
     bab.Append(((byte[])encoded.Array()), encoded.Position(), encoded.Remaining());
     return bab;
 }
 private static ByteArrayBuffer Encode(Encoding charset, string @string)
 {
     ByteBuffer encoded = charset.Encode(CharBuffer.Wrap(@string));
     ByteArrayBuffer bab = new ByteArrayBuffer(encoded.Remaining());
     bab.Append(((byte[])encoded.Array()), encoded.Position(), encoded.Remaining());
     return bab;
 }
		/// <exception cref="System.IO.IOException"></exception>
		public static byte[] Read(InputStream @is)
		{
			int initialCapacity = 1024;
			ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(initialCapacity);
			byte[] bytes = new byte[512];
			int offset = 0;
			int numRead = 0;
			while ((numRead = @is.Read(bytes, offset, bytes.Length - offset)) >= 0)
			{
				byteArrayBuffer.Append(bytes, 0, numRead);
				offset += numRead;
			}
			return byteArrayBuffer.ToByteArray();
		}
        /// <exception cref="System.IO.IOException"></exception>
        public static byte[] Read(InputStream @is)
        {
            int             initialCapacity = 1024;
            ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(initialCapacity);

            byte[] bytes   = new byte[512];
            int    offset  = 0;
            int    numRead = 0;

            while ((numRead = @is.Read(bytes, offset, bytes.Length - offset)) >= 0)
            {
                byteArrayBuffer.Append(bytes, 0, numRead);
                offset += numRead;
            }
            return(byteArrayBuffer.ToByteArray());
        }
Exemple #7
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_id);
     buffer.WriteInt(Length());
     buffer.Append(_bytes);
 }
Exemple #8
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_id);
     buffer.WriteInt(Length());
     buffer.Append(_bytes);
 }