in src/main/java/org/apache/commons/mail/ByteArrayDataSource.java [137:176]
private void byteArrayDataSource(final InputStream aIs)
throws IOException
{
BufferedInputStream bis = null;
BufferedOutputStream osWriter = null;
try
{
int length = 0;
final byte[] buffer = new byte[ByteArrayDataSource.BUFFER_SIZE];
bis = new BufferedInputStream(aIs);
baos = new ByteArrayOutputStream();
osWriter = new BufferedOutputStream(baos);
// Write the InputData to OutputStream
while ((length = bis.read(buffer)) != -1)
{
osWriter.write(buffer, 0, length);
}
osWriter.flush();
osWriter.close();
}
finally
{
if (bis != null)
{
bis.close();
}
if (baos != null)
{
baos.close();
}
if (osWriter != null)
{
osWriter.close();
}
}
}