Code example for ByteArrayInputStream

Methods: close

0
        messageBodyPart.setDataHandler(new DataHandler(dataSource));
      } 
      else 
      { 
        // Normal Content 
        final ByteArrayInputStream bin = new ByteArrayInputStream(data);
        final String contentId = (String) item.getContentId();
        final ByteArrayDataSource dataSource = new ByteArrayDataSource(bin, item.getMimeType());
        final MimeBodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setDataHandler(new DataHandler(dataSource));
        messageBodyPart.setHeader("Content-ID", contentId);
        repository.getMultipart().addBodyPart(messageBodyPart);
        bin.close();
      } 
    } 
    catch (Exception e)
    { 
      throw new IOException("Error closing stream: " + e.getMessage());
    } 
    closed = true;