ByteArrayOutputStream output = new ByteArrayOutputStream(largeDataSize);
for (int i = 0; i < largeDataSize; i++)
output.write(i);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
// Send data in 512 byte chunks.
connection.addListener(new InputStreamSender(input, 512) {
protected void start () {
// Normally would send an object so the receiving side knows how to handle the chunks we are about to send.
System.out.println("starting");
}