@Test public void append() throws Exception { String data1 = "פרק ראשון ובו יסופר יסופר"; String data2 = "פרק שני ובו יסופר יסופר"; BufferWritable bw1 = new BufferWritable(data1.getBytes()); assertArrayEquals(data1.getBytes(), bw1.buf); bw1.append(data2.getBytes()); assertArrayEquals((data1+data2).getBytes(), bw1.buf); }
public void append(byte[] app) { if (buf == null) { buf = app; return; } if (app == null) { return; } byte[] newbuf = new byte[buf.length + app.length]; System.arraycopy(buf, 0, newbuf, 0, buf.length); System.arraycopy(app, 0, newbuf, buf.length, app.length); buf = newbuf; }
BufferWritable implements Writable { public void append(byte[] app) { if (buf == null) { buf = app; return; } if (app == null) { return; } byte[] newbuf = new byte[buf.length + app.length]; System.arraycopy(buf, 0, newbuf, 0, buf.length); System.arraycopy(app, 0, newbuf, buf.length, app.length); buf = newbuf; } }
BufferWritable implements Writable { public void append(byte[] app) { if (buf == null) { buf = app; return; } if (app == null) { return; } byte[] newbuf = new byte[buf.length + app.length]; System.arraycopy(buf, 0, newbuf, 0, buf.length); System.arraycopy(app, 0, newbuf, buf.length, app.length); buf = newbuf; } BufferWritable(byte[] inBuf); }
BufferWritable implements Writable { public void append(byte[] app) { if (buf == null) { buf = app; return; } if (app == null) { return; } byte[] newbuf = new byte[buf.length + app.length]; System.arraycopy(buf, 0, newbuf, 0, buf.length); System.arraycopy(app, 0, newbuf, buf.length, app.length); buf = newbuf; } BufferWritable(byte[] inBuf); @Override void write(DataOutput out); @Override void readFields(DataInput in); void append(byte[] app); }
BufferWritable implements Writable { public void append(byte[] app) { if (buf == null) { buf = app; return; } if (app == null) { return; } byte[] newbuf = new byte[buf.length + app.length]; System.arraycopy(buf, 0, newbuf, 0, buf.length); System.arraycopy(app, 0, newbuf, buf.length, app.length); buf = newbuf; } BufferWritable(byte[] inBuf); @Override void write(DataOutput out); @Override void readFields(DataInput in); void append(byte[] app);  }