当前位置: 首页>>代码示例>>Java>>正文


Java CharEncoding.UTF_8属性代码示例

本文整理汇总了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());
        }
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:22,代码来源:MailService.java

示例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);
    }
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:19,代码来源:MailService.java

示例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());
        }
    }
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:23,代码来源:MailService.java

示例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);
    }
}
 
开发者ID:ElectronicArmory,项目名称:Armory,代码行数:19,代码来源:MailService.java

示例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());
        }
    }
}
 
开发者ID:megadotnet,项目名称:SpringBootDemoApp,代码行数:22,代码来源:MailService.java

示例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();
    }
}
 
开发者ID:SoftwareDefinedBuildings,项目名称:bw2android,代码行数:17,代码来源:BosswaveClientTest.java

示例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);
    }
}
 
开发者ID:benoyprakash,项目名称:java-hostel,代码行数:20,代码来源:MailService.java

示例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());
    }
}
 
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:19,代码来源:MailService.java

示例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());
		}
	}
}
 
开发者ID:alikemalocalan,项目名称:MicroBlog,代码行数:23,代码来源:MailService.java

示例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);
    }
}
 
开发者ID:anitechcs,项目名称:tquesto,代码行数:20,代码来源:MailServiceImpl.java

示例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);

}
 
开发者ID:uustory,项目名称:U8Server,代码行数:33,代码来源:RSASignature.java

示例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);
    }
}
 
开发者ID:yegor256,项目名称:rexsl,代码行数:31,代码来源:XsltFilter.java

示例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;
    }
}
 
开发者ID:SoftwareDefinedBuildings,项目名称:bw2android,代码行数:9,代码来源:Frame.java

示例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);
}
 
开发者ID:SoftwareDefinedBuildings,项目名称:bw2android,代码行数:10,代码来源:FrameTest.java

示例15: readBodyAsString

/**
 * 以字符串的形式去读取请求的消息体
 * @author nan.li
 * @return
 */
public String readBodyAsString()
{
    try
    {
        return new String(body, CharEncoding.UTF_8);
    }
    catch (UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:httpkit,代码行数:17,代码来源:HttpReader.java


注:本文中的org.apache.commons.lang3.CharEncoding.UTF_8属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。