Return the sizes of all messages in this folder, as returned by the POP3 LIST command. Each entry in the array corresponds to a message; entry i corresponds to message number i+1 . @return array of message sizes @exception IllegalStateException if the folder isn't open @exception Mes
()
| 493 | * @since JavaMail 1.3.3 |
| 494 | */ |
| 495 | public synchronized int[] getSizes() throws MessagingException { |
| 496 | checkOpen(); |
| 497 | int sizes[] = new int[total]; |
| 498 | InputStream is = null; |
| 499 | LineInputStream lis = null; |
| 500 | try { |
| 501 | is = port.list(); |
| 502 | lis = new LineInputStream(is); |
| 503 | String line; |
| 504 | while ((line = lis.readLine()) != null) { |
| 505 | try { |
| 506 | StringTokenizer st = new StringTokenizer(line); |
| 507 | int msgnum = Integer.parseInt(st.nextToken()); |
| 508 | int size = Integer.parseInt(st.nextToken()); |
| 509 | if (msgnum > 0 && msgnum <= total) |
| 510 | sizes[msgnum - 1] = size; |
| 511 | } catch (RuntimeException e) { |
| 512 | } |
| 513 | } |
| 514 | } catch (IOException ex) { |
| 515 | // ignore it? |
| 516 | } finally { |
| 517 | try { |
| 518 | if (lis != null) |
| 519 | lis.close(); |
| 520 | } catch (IOException cex) { } |
| 521 | try { |
| 522 | if (is != null) |
| 523 | is.close(); |
| 524 | } catch (IOException cex) { } |
| 525 | } |
| 526 | return sizes; |
| 527 | } |
| 528 | |
| 529 | /** |
| 530 | * Return the raw results of the POP3 LIST command with no arguments. |