Esempio n. 1
0
 public int sendAttachmentAndReturnSize(final Attachment attachment) throws IOException {
   final InputStream readAsStream = attachment.readAsStream();
   int i = 0;
   while (readAsStream.read() != -1) {
     i++;
   }
   readAsStream.close();
   return i;
 }
Esempio n. 2
0
 private String readAttachmentStart(final Attachment attachment) {
   final byte[] byteArray = new byte[ATTACHMENT_START];
   try {
     final InputStream input = attachment.readAsStream();
     final int nbrBytes = input.read(byteArray, 0, byteArray.length);
     if (nbrBytes < 1) {
       throw new IOException("Empty Attachment."); // $NON-NLS-1$
     }
   } catch (final IOException e) {
     return "[can't read " + attachment + "]"; // $NON-NLS-1$ //$NON-NLS-2$
   }
   return new String(byteArray);
 }