本文整理汇总了Java中org.apache.commons.lang3.CharEncoding.UTF_8属性的典型用法代码示例。如果您正苦于以下问题:Java CharEncoding.UTF_8属性的具体用法?Java CharEncoding.UTF_8怎么用?Java CharEncoding.UTF_8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.lang3.CharEncoding
的用法示例。
在下文中一共展示了CharEncoding.UTF_8属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendEmail
void sendEmail(String to, String subject, String content, String from) {
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
false, true, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(from);
message.setSubject(subject);
message.setText(content, true);
javaMailSender.send(mimeMessage);
log.debug("Sent email to User '{}'", to);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.warn("Email could not be sent to user '{}'", to, e);
} else {
log.warn("Email could not be sent to user '{}': {}", to, e.getMessage());
}
}
}
示例2: sendEmail
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(jHipsterProperties.getMail().getFrom());
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent email to User '{}'", to);
} catch (Exception e) {
log.warn("Email could not be sent to user '{}'", to, e);
}
}
示例3: sendEmail
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(jHipsterProperties.getMail().getFrom());
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent email to User '{}'", to);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.warn("Email could not be sent to user '{}'", to, e);
} else {
log.warn("Email could not be sent to user '{}': {}", to, e.getMessage());
}
}
}
示例4: sendEmail
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send e-mail[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(jHipsterProperties.getMail().getFrom());
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent e-mail to User '{}'", to);
} catch (Exception e) {
log.warn("E-mail could not be sent to user '{}'", to, e);
}
}
示例5: sendEmail
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}", isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(mailFromDisplay);
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent email to User '{}'", to);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.warn("Email could not be sent to user '{}'", to, e);
} else {
log.warn("Email could not be sent to user '{}': {}", to, e.getMessage());
}
}
}
示例6: onResultReceived
@Override
public void onResultReceived(BosswaveResult result) {
assertEquals(result.getPayloadObjects().size(), 1);
byte[] messageContent = result.getPayloadObjects().get(0).getContent();
String messageText;
try {
messageText = new String(messageContent, CharEncoding.UTF_8);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Platform doesn't support UTF-8", e);
}
assertTrue(expectedMessages.contains(messageText));
counter++;
if (counter == expectedMessages.size()) {
sem.release();
}
}
示例7: sendEmail
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(jHipsterProperties.getMail().getFrom());
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent email to User '{}'", to);
} catch (Exception e) {
log.warn("Email could not be sent to user '{}'", to, e);
}
}
示例8: sendEmail
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send e-mail[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(jHipsterProperties.getMail().getFrom());
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent e-mail to User '{}'", to);
} catch (Exception e) {
log.warn("E-mail could not be sent to user '{}', exception is: {}", to, e.getMessage());
}
}
示例9: sendEmail
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(jHipsterProperties.getMail().getFrom());
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent email to User '{}'", to);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.warn("Email could not be sent to user '{}'", to, e);
} else {
log.warn("Email could not be sent to user '{}': {}", to, e.getMessage());
}
}
}
示例10: sendEmail
@Async
@Override
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
log.debug("Send e-mail[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
isMultipart, isHtml, to, subject, content);
// Prepare message using a Spring helper
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(tquestoProperties.getMail().getFrom());
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
log.debug("Sent e-mail to User '{}'", to);
} catch (Exception e) {
log.warn("E-mail could not be sent to user '{}'", to, e);
}
}
示例11: sign
/**
* RSA签名
*
* @param content
* 待签名数据
* @param privateKey
* 商户私钥
* @param encode
* 字符集编码
* @return 签名值
* @throws java.io.IOException
* @throws java.security.NoSuchAlgorithmException
* @throws java.security.spec.InvalidKeySpecException
* @throws java.security.SignatureException
* @throws java.security.InvalidKeyException
*/
public static String sign(String content, String privateKey, String encode) throws IOException,
NoSuchAlgorithmException, InvalidKeySpecException, SignatureException, InvalidKeyException {
String charset = CharEncoding.UTF_8;
if (!StringUtils.isBlank(encode)) {
charset = encode;
}
PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(com.u8.server.sdk.jinli.jinli.Base64.decode(privateKey));
KeyFactory keyf = KeyFactory.getInstance("RSA");
PrivateKey priKey = keyf.generatePrivate(priPKCS8);
java.security.Signature signature = java.security.Signature.getInstance(SIGN_ALGORITHMS);
signature.initSign(priKey);
signature.update(content.getBytes(charset));
byte[] signed = signature.sign();
return com.u8.server.sdk.jinli.jinli.Base64.encodeBytes(signed);
}
示例12: filter
/**
* Make filtering (when necessary) or pass through if it's not an XML
* document.
* @param request The request
* @param response The response
* @param chain Filter chain
* @throws IOException If something goes wrong
* @throws ServletException If something goes wrong
* @checkstyle ThrowsCount (6 lines)
* @checkstyle RedundantThrows (5 lines)
*/
private void filter(final HttpServletRequest request,
final HttpServletResponse response, final FilterChain chain)
throws IOException, ServletException {
final ByteArrayResponseWrapper wrapper =
new ByteArrayResponseWrapper(response);
chain.doFilter(request, wrapper);
if (!response.isCommitted()) {
byte[] data = wrapper.getByteArray();
String page = new String(data, CharEncoding.UTF_8);
final PageAnalyzer analyzer = new PageAnalyzer(page, request);
if (analyzer.needsTransformation()) {
page = this.transform(page);
data = page.getBytes(CharEncoding.UTF_8);
response.setContentType(MediaType.TEXT_HTML);
response.setCharacterEncoding(CharEncoding.UTF_8);
response.setContentLength(data.length);
}
response.getOutputStream().write(data);
}
}
示例13: readLineFromStream
private static String readLineFromStream(InputStream stream) throws IOException {
byte[] bytes = readUntil(stream, (byte)'\n');
String line = new String(bytes, CharEncoding.UTF_8);
if (line.endsWith("\n")) {
return line.substring(0, line.length() - 1);
} else {
return line;
}
}
示例14: testGetFirstValue
@Test
public void testGetFirstValue() throws UnsupportedEncodingException {
Frame.Builder builder = new Frame.Builder(Command.PUBLISH, 410);
builder.addKVPair("testKey", "testValue1");
builder.addKVPair("testKey", "testValue2"); // Redundant key/value pair
Frame frame = builder.build();
String firstValue = new String(frame.getFirstValue("testKey"), CharEncoding.UTF_8);
assertEquals("testValue1", firstValue);
}
示例15: readBodyAsString
/**
* 以字符串的形式去读取请求的消息体
* @author nan.li
* @return
*/
public String readBodyAsString()
{
try
{
return new String(body, CharEncoding.UTF_8);
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
return null;
}