|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
how to detect empty attachments?Hi,
from time to time I receive mails with empty attachments, i.e. the message contains a part which marked as attachment but has zero length. I would like to filter out such attachments without reading and it looks like the condition "part.getInputStream().available() == 0" can be used for this purpose, but it is not documented, that this method must return non-zero for non-empty streams, so I decided to check here if I can use check or I must read the stream to find out that the stream is empty. Thanks in advance, Oleg. =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: how to detect empty attachments?Oleg Sukhodolsky wrote:
> Hi, > > from time to time I receive mails with empty attachments, i.e. the > message contains a part which marked as attachment but has > zero length. I would like to filter out such attachments > without reading and it looks like the condition > "part.getInputStream().available() == 0" can be used for this purpose, > but it is not documented, that this method must return non-zero for non-empty > streams, so I decided to check here if I can use check or I must read > the stream to find out that the stream is empty. You need to read the stream. You might want to try Part.getSize first. If it returns a non-negative number, it should be correct. =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: how to detect empty attachments?On Thu, Dec 4, 2008 at 9:51 PM, Bill Shannon <bill.shannon@...> wrote:
> Oleg Sukhodolsky wrote: >> >> Hi, >> >> from time to time I receive mails with empty attachments, i.e. the >> message contains a part which marked as attachment but has >> zero length. I would like to filter out such attachments >> without reading and it looks like the condition >> "part.getInputStream().available() == 0" can be used for this purpose, >> but it is not documented, that this method must return non-zero for >> non-empty >> streams, so I decided to check here if I can use check or I must read >> the stream to find out that the stream is empty. > > You need to read the stream. > > You might want to try Part.getSize first. If it returns a non-negative > number, it should be correct. > Thanks for suggestion.I will try it. Oleg. =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
| Free embeddable forum powered by Nabble | Forum Help |