本文整理匯總了Java中javax.mail.Header.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Header.getName方法的具體用法?Java Header.getName怎麽用?Java Header.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.mail.Header
的用法示例。
在下文中一共展示了Header.getName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseDescriptionFile
import javax.mail.Header; //導入方法依賴的package包/類
/**
* Parses metadata stored in a Debian Control File-like format.
*
* @see <a href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html#The-DESCRIPTION-file">Description File</a>
*/
public static Map<String, String> parseDescriptionFile(final InputStream in) {
checkNotNull(in);
try {
LinkedHashMap<String, String> results = new LinkedHashMap<>();
InternetHeaders headers = new InternetHeaders(in);
Enumeration headerEnumeration = headers.getAllHeaders();
while (headerEnumeration.hasMoreElements()) {
Header header = (Header) headerEnumeration.nextElement();
String name = header.getName();
String value = header.getValue()
.replace("\r\n", "\n")
.replace("\r", "\n"); // TODO: "should" be ASCII only, otherwise need to know encoding?
results.put(name, value); // TODO: Supposedly no duplicates, is this true?
}
return results;
} catch (MessagingException e) {
throw new RException(null, e);
}
}
示例2: getHeaders
import javax.mail.Header; //導入方法依賴的package包/類
protected MessageHeaders getHeaders(MimeMessage message) throws MessagingException {
Map<String, String> headerMap = new HashMap<>();
// oh wow 2015 and it's untyped and uses Enumeration
Enumeration allHeaders = message.getAllHeaders();
while (allHeaders.hasMoreElements()) {
Header header = (Header) allHeaders.nextElement();
String headerName = header.getName();
String headerVal = header.getValue();
headerMap.put(headerName, headerVal);
}
return new MessageHeaders(headerMap);
}
示例3: createLog
import javax.mail.Header; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private static String createLog(final Message msg) {
StringBuilder bldr = new StringBuilder();
Enumeration<Header> allHeaders;
try {
allHeaders = msg.getAllHeaders();
} catch (MessagingException e) {
return null;
}
while (allHeaders.hasMoreElements()) {
Header header = allHeaders.nextElement();
String name = header.getName();
String value = header.getValue();
bldr.append(name);
bldr.append(":");
bldr.append(value);
bldr.append("\n");
}
return StringUtils.truncate(bldr.toString(), LOG_FIELD_WIDTH);
}
示例4: main
import javax.mail.Header; //導入方法依賴的package包/類
public static void main(String[] args) throws SUTimeParsingError, MessagingException {
HashMap<String,String> hm=new HashMap<String,String>();
hm.put("kk","ghhj");
for(java.util.Map.Entry<String, String> e: hm.entrySet()){
//System.out.println("Key " + e.getKey());
//System.out.println("Value " + e.getValue());
}
String s="NextPart_000_005D_01CC73D5.3BA43FB0\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: quoted-printable\n\nStuff:\n\n Please read this stuff at the beginning of each week. =\nFeel free to discuss it throughout the week.\n\n\n--=20\n\nMrs. Suzy M. Smith\n555-555-5555\[email protected]\n------=_NextPart_000_005D_01CC73D5.3BA43FB0\nContent-Type: text/html;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: quoted-printable\n\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<HTML><HEAD>\n<META content=3D\"text/html; charset=3Diso-8859-1\" =\nhttp-equiv=3DContent-Type>\n<META name=3DGENERATOR content=3D\"MSHTML 9.00.8112.16434\">\n<STYLE></STYLE>\n</HEAD>\n<BODY bgColor=3D#ffffff>\n<DIV>\n<P style=3D\"MARGIN: 0in 0in 0pt\" class=3DMsoNormal><SPAN=20\nstyle=3D\"mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New =\nRoman'; mso-bidi-font-family: 'Times New =\nRoman'\">Stuff:<?xml:namespace=20\nprefix =3D o ns =3D \"urn:schemas-microsoft-com:office:office\"=20\n/><o:p></o:p></SPAN></P>\n<P style=3D\"MARGIN: 0in 0in 0pt\" class=3DMsoNormal><SPAN=20\nstyle=3D\"mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New =\nRoman'; mso-bidi-font-family: 'Times New Roman'\"><SPAN=20\nstyle=3D\"mso-tab-count: =\n1\"> =20\n</SPAN></SPAN>Please read this stuff at the beginning of each =\nweek. Feel=20\nfree to discuss it throughout the week.<SPAN=20\nstyle=3D\"mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New =\nRoman'; mso-bidi-font-family: 'Times New =\nRoman'\"><o:p></o:p></SPAN></P></DIV>\n<DIV><BR>-- <BR><BR>Mrs. Suzy M. Smith<BR>555-555-5555<BR><A=20\nhref=3D\"mailto:[email protected]\">[email protected]</A></DIV></BODY=\n></HTML>\n\n------=_NextPart_000_005D_01CC73D5.3BA43FB0--\n\n";
InputStream stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
Session ss = Session.getDefaultInstance(new Properties());
MimeMessage mi=new MimeMessage(ss,stream);
mi.getAllHeaderLines();
for (Enumeration<Header> e = mi.getAllHeaders(); e.hasMoreElements();) {
Header h = e.nextElement();
String name=h.getName();
String value=h.getValue();
System.out.println(value);
h.getValue();
}
//System.out.println("String: " + s);
//parse(s);
System.out.println();
}
示例5: run_me
import javax.mail.Header; //導入方法依賴的package包/類
@SuppressLint("NewApi") public static void run_me(ArrayList<String> args) throws MessagingException {
//HashMap<String,String> hm=new HashMap<String,String>();
//hm.put("kk","ghhj");
/*for(java.util.Map.Entry<String, String> e: hm.entrySet()){
//System.out.println("Key " + e.getKey());
//System.out.println("Value " + e.getValue());
}
*/
for(String s:args)
{
// String s="";
InputStream stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
Session ss = Session.getDefaultInstance(new Properties());
MimeMessage mi=new MimeMessage(ss,stream);
mi.getAllHeaderLines();
for (Enumeration<Header> e = mi.getAllHeaders(); e.hasMoreElements();) {
Header h = e.nextElement();
String name=h.getName();
String value=h.getValue();
System.out.println(value);
System.out.println(name);
h.getValue();
}
System.out.println("String: " + s);
// parse(s);
System.out.println();
}
}
示例6: bodyPartRequest
import javax.mail.Header; //導入方法依賴的package包/類
private Response bodyPartRequest(final MimeBodyPart body, final Map<String, String> references) throws Exception {
@SuppressWarnings("unchecked")
final Enumeration<Header> en = body.getAllHeaders();
Header header = en.nextElement();
final String request =
header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : "");
final Matcher matcher = REQUEST_PATTERN.matcher(request);
final Matcher matcherRef = BATCH_REQUEST_REF_PATTERN.matcher(request);
final MultivaluedMap<String, String> headers = new MultivaluedHashMap<String, String>();
while (en.hasMoreElements()) {
header = en.nextElement();
headers.putSingle(header.getName(), header.getValue());
}
final Response res;
final String url;
final String method;
if (matcher.find()) {
url = matcher.group(2);
method = matcher.group(1);
} else if (matcherRef.find()) {
url = references.get(matcherRef.group(2)) + matcherRef.group(3);
method = matcherRef.group(1);
} else {
url = null;
method = null;
}
if (url == null) {
res = null;
} else {
final WebClient client = WebClient.create(url, "odatajclient", "odatajclient", null);
client.headers(headers);
if ("DELETE".equals(method)) {
res = client.delete();
} else {
final InputStream is = body.getDataHandler().getInputStream();
String content = IOUtils.toString(is);
IOUtils.closeQuietly(is);
final Matcher refs = REF_PATTERN.matcher(content);
while (refs.find()) {
content = content.replace(refs.group(1), references.get(refs.group(1)));
}
if ("PATCH".equals(method) || "MERGE".equals(method)) {
client.header("X-HTTP-METHOD", method);
res = client.invoke("POST", IOUtils.toInputStream(content));
} else {
res = client.invoke(method, IOUtils.toInputStream(content));
}
}
// When updating to CXF 3.0.1, uncomment the following line, see CXF-5865
// client.close();
}
return res;
}