final InputStream byteStream = input.getByteStream();
if (byteStream != null)
{
try
{
final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream();
IOUtils.getInstance().copyStreams(byteStream, bout);
return bout.toByteArray();
}
finally
{
byteStream.close();
}
}
final Reader characterStream = input.getCharacterStream();
if (characterStream == null)
{
throw new IOException
("InputSource has neither an Byte nor a CharacterStream");
}
try
{
final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream();
final OutputStreamWriter owriter = new OutputStreamWriter(bout);
IOUtils.getInstance().copyWriter(characterStream, owriter);
owriter.close();
return bout.toByteArray();
}
finally
{
characterStream.close();
}