MailTransportUtils { public static InternetAddress getTo(URI uri) { Matcher matcher = TO_PATTERN.matcher(uri.getSchemeSpecificPart()); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { String group = matcher.group(i); if (group != null) { try { return new InternetAddress(group); } catch (AddressException e) { } } } } return null; } private  MailTransportUtils(); static InternetAddress getTo(URI uri); static String getSubject(URI uri); static void closeService(Service service); static void closeFolder(Folder folder); static void closeFolder(Folder folder, boolean expunge); static String toPasswordProtectedString(URLName name); static URI toUri(InternetAddress to, String subject);  }
@Test public void testGetTo() throws Exception { URI uri = new URI("mailto:infobot@example.com?subject=current-issue"); InternetAddress to = MailTransportUtils.getTo(uri); Assert.assertEquals("Invalid destination", new InternetAddress("infobot@example.com"), to); uri = new URI("mailto:infobot@example.com"); to = MailTransportUtils.getTo(uri); Assert.assertEquals("Invalid destination", new InternetAddress("infobot@example.com"), to); }