本文整理汇总了Java中org.apache.commons.codec.CharEncoding.UTF_8属性的典型用法代码示例。如果您正苦于以下问题:Java CharEncoding.UTF_8属性的具体用法?Java CharEncoding.UTF_8怎么用?Java CharEncoding.UTF_8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.codec.CharEncoding
的用法示例。
在下文中一共展示了CharEncoding.UTF_8属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendEmail
@Async
public void sendEmail(final String to, final String subject, final String content, final boolean isMultipart,
final boolean isHtml) {
final MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setFrom(uaaProperties.getMail().getFrom());
message.setTo(to);
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
LOGGER.debug("Sent email to User '{}' with subject '{}'", to, subject);
} catch (final MessagingException | MailException e) {
LOGGER.warn("Mail could not be sent to user '{}'", to, e);
}
}
示例2: testUTF8RoundTrip
@Test
public void testUTF8RoundTrip() throws Exception {
final String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
final QCodec qcodec = new QCodec(CharEncoding.UTF_8);
assertEquals(
"=?UTF-8?Q?=D0=92=D1=81=D0=B5=D0=BC=5F=D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D1=82?=",
qcodec.encode(ru_msg)
);
assertEquals("=?UTF-8?Q?Gr=C3=BCezi=5Fz=C3=A4m=C3=A4?=", qcodec.encode(ch_msg));
assertEquals(ru_msg, qcodec.decode(qcodec.encode(ru_msg)));
assertEquals(ch_msg, qcodec.decode(qcodec.encode(ch_msg)));
}
示例3: getEntity
@Override
public UrlEncodedFormEntity getEntity() throws BoxRestException {
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
for (Map.Entry<String, Object> entry : getJSONEntity().entrySet()) {
Object value = entry.getValue();
if (value != null && value instanceof String) {
pairs.add(new BasicNameValuePair(entry.getKey(), (String) entry.getValue()));
}
}
try {
return new UrlEncodedFormEntity(pairs, CharEncoding.UTF_8);
}
catch (UnsupportedEncodingException e) {
throw new BoxRestException(e);
}
}
示例4: sendEmail
private void sendEmail(String to, String subject, String content, String from, boolean isMultipart, boolean isHtml) {
MimeMessage mimeMessage = mailSender.createMimeMessage();
try {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
message.setTo(to);
message.setFrom(new InternetAddress(from, internetaddress));
message.setSubject(subject);
message.setText(content, isHtml);
mailSender.send(mimeMessage);
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: testUTF8RoundTrip
@Test
public void testUTF8RoundTrip() throws Exception {
final String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
final BCodec bcodec = new BCodec(CharEncoding.UTF_8);
assertEquals("=?UTF-8?B?0JLRgdC10Lxf0L/RgNC40LLQtdGC?=", bcodec.encode(ru_msg));
assertEquals("=?UTF-8?B?R3LDvGV6aV96w6Rtw6Q=?=", bcodec.encode(ch_msg));
assertEquals(ru_msg, bcodec.decode(bcodec.encode(ru_msg)));
assertEquals(ch_msg, bcodec.decode(bcodec.encode(ch_msg)));
}
示例6: exportConcept
/**
* Export concept to SNOMED CT Release Format 2.
* @param conceptId
* @throws DrugMatchConfigurationException
* @throws IOException
*/
private void exportConcept(final String conceptId) throws DrugMatchConfigurationException, IOException {
boolean addHeader = false;
if (this.fileNameConcept == null) {
this.fileNameConcept = DrugMatchProperties.getTerminologyDirectory().getPath() + File.separator + "sct2_Concept_DrugMatch_" + this.isoNow + ".txt";
addHeader = true;
}
try (CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(this.fileNameConcept,
!addHeader), // append
CharEncoding.UTF_8),
ReleaseFormat2.FILE_CONTENT_SEPARATOR_CHARACTER,
CSVWriter.NO_QUOTE_CHARACTER,
ReleaseFormat2.NEW_LINE)) {
// header
if (addHeader) {
writer.writeNext(new String[] {
"id",
"effectiveTime",
"active",
"moduleId",
"definitionStatusId"
});
log.info("Created {}", this.fileNameConcept);
}
// content
writer.writeNext(new String[] {
conceptId,
this.effectiveTime,
ReleaseFormat2.STATUS_ACTIVE_ID,
DrugMatchProperties.getModuleId(),
ReleaseFormat2.CONCEPT_DEFINITION_STATUS_PRIMITIVE_ID
});
writer.flush();
}
}
示例7: exportMapping
/**
* Export 1-1 mapping: Drug ID to SCT Concept ID.
* @param pharmaceutical2ConceptId
* @throws DrugMatchConfigurationException
* @throws IOException
*/
private void exportMapping(final Map<Pharmaceutical, String> pharmaceutical2ConceptId) throws DrugMatchConfigurationException, IOException {
if (pharmaceutical2ConceptId.size() > 0) {
log.info("Starting \"Create\" mapping export");
String fullFileName = DrugMatchProperties.getMappingDirectory().getPath() + File.separator + "mapping_" + this.isoNow + ".csv";
String quoteCharacter = DrugMatchProperties.getFileContentQuoteCharacter();
char quoteChar = (quoteCharacter == null) ? CSVWriter.NO_QUOTE_CHARACTER : quoteCharacter.charAt(0);
try (CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(fullFileName),
CharEncoding.UTF_8),
Check.getOutputFileContentSeparator(),
quoteChar,
System.lineSeparator())) {
// header
writer.writeNext(new String[] {
"Drug ID",
"SCT Concept ID"
});
// content
for (Map.Entry<Pharmaceutical, String> entry : pharmaceutical2ConceptId.entrySet()) {
writer.writeNext(new String[] {
entry.getKey().drugId,
entry.getValue()
});
}
writer.flush();
log.info("Created {}", fullFileName);
}
log.info("Completed \"Create\" mapping export");
} else {
log.debug("Skipping mapping export, cause: no data available");
}
}
示例8: exportPreferredEnglishToLanguageReferenceSet
/**
* Export English description to SNOMED CT Release Format 2 Language Reference Set.
* @param descriptionId
* @throws DrugMatchConfigurationException
* @throws IOException
*/
private void exportPreferredEnglishToLanguageReferenceSet(final String descriptionId) throws DrugMatchConfigurationException, IOException {
boolean addHeader = false;
if (this.fileNameReferenceSetLanguageEnglish == null) {
this.fileNameReferenceSetLanguageEnglish = DrugMatchProperties.getReferenceSetLanguageDirectory().getPath() + File.separator + "der2_cRefset_Language_DrugMatch_" + ReleaseFormat2.LANGUAGE_EN_CODE + "_" + this.isoNow + ".txt";
addHeader = true;
}
try (CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(this.fileNameReferenceSetLanguageEnglish,
!addHeader), // append
CharEncoding.UTF_8),
ReleaseFormat2.FILE_CONTENT_SEPARATOR_CHARACTER,
CSVWriter.NO_QUOTE_CHARACTER,
ReleaseFormat2.NEW_LINE)) {
// header
if (addHeader) {
writer.writeNext(LANGUAGE_REFSET_HEADER);
log.info("Created {}", this.fileNameReferenceSetLanguageEnglish);
}
// content
writer.writeNext(new String[] {
UUID.randomUUID().toString(), // UUID v4 as defined by Robert Turnbull (20140603, [email protected])
this.effectiveTime,
ReleaseFormat2.STATUS_ACTIVE_ID,
DrugMatchProperties.getModuleId(),
ReleaseFormat2.REFERENCE_SET_LANGUAGE_US_ENGLISH_ID,
descriptionId,
ReleaseFormat2.META_DATA_ACCEPTABILITY_PREFERRED_ID
});
writer.flush();
}
}
示例9: exportPreferredNationalToLanguageReferenceSet
/**
* Export national description to SNOMED CT Release Format 2 Language Reference Set.
* @param descriptionId
* @throws DrugMatchConfigurationException
* @throws IOException
*/
private void exportPreferredNationalToLanguageReferenceSet(final String descriptionId) throws DrugMatchConfigurationException, IOException {
boolean addHeader = false;
if (this.fileNameReferenceSetLanguageNational == null) {
this.fileNameReferenceSetLanguageNational = DrugMatchProperties.getReferenceSetLanguageDirectory().getPath() + File.separator + "der2_cRefset_Language_DrugMatch_" + DrugMatchProperties.getNationalLanguageCode() + "_" + this.isoNow + ".txt";
addHeader = true;
}
try (CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(this.fileNameReferenceSetLanguageNational,
!addHeader), // append
CharEncoding.UTF_8),
ReleaseFormat2.FILE_CONTENT_SEPARATOR_CHARACTER,
CSVWriter.NO_QUOTE_CHARACTER,
ReleaseFormat2.NEW_LINE)) {
// header
if (addHeader) {
writer.writeNext(LANGUAGE_REFSET_HEADER);
log.info("Created {}", this.fileNameReferenceSetLanguageNational);
}
// content
writer.writeNext(new String[] {
UUID.randomUUID().toString(), // UUID v4 as defined by Robert Turnbull (20140603, [email protected])
this.effectiveTime,
ReleaseFormat2.STATUS_ACTIVE_ID,
DrugMatchProperties.getModuleId(),
DrugMatchProperties.getLanguageReferenceSetId(),
descriptionId,
ReleaseFormat2.META_DATA_ACCEPTABILITY_PREFERRED_ID
});
writer.flush();
}
}
示例10: reportCoreConcept
/**
* Export concept to "Create" report.
* @param conceptId
* @param fullySpecifiedName
* @throws DrugMatchConfigurationException
* @throws IOException
*/
private void reportCoreConcept(final String conceptId,
String fullySpecifiedName) throws DrugMatchConfigurationException, IOException {
boolean addHeader = false;
if (this.fileNameReportCoreConcept == null) {
this.fileNameReportCoreConcept = DrugMatchProperties.getReportDirectory().getPath() + File.separator + "create_generic_pharmaceutical_" + this.isoNow + ".txt";
addHeader = true;
}
String quoteCharacter = DrugMatchProperties.getFileContentQuoteCharacter();
char quoteChar = (quoteCharacter == null) ? CSVWriter.NO_QUOTE_CHARACTER : quoteCharacter.charAt(0);
try (CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(this.fileNameReportCoreConcept,
!addHeader), // append
CharEncoding.UTF_8),
Check.getOutputFileContentSeparator(),
quoteChar,
System.lineSeparator())) {
// header
if (addHeader) {
writer.writeNext(REPORT_HEADER);
log.info("Created {}", this.fileNameReportCoreConcept);
}
// content
writer.writeNext(new String[] {
conceptId,
fullySpecifiedName
});
writer.flush();
}
}
示例11: reportExtensionConcept
/**
* Export concept to "Create" report.
* @param conceptId
* @param fullySpecifiedName
* @throws DrugMatchConfigurationException
* @throws IOException
*/
private void reportExtensionConcept(final String conceptId,
String fullySpecifiedName) throws DrugMatchConfigurationException, IOException {
boolean addHeader = false;
if (this.fileNameReportExtensionConcept == null) {
this.fileNameReportExtensionConcept = DrugMatchProperties.getReportDirectory().getPath() + File.separator + "create_national_pharmaceutical_" + this.isoNow + ".txt";
addHeader = true;
}
String quoteCharacter = DrugMatchProperties.getFileContentQuoteCharacter();
char quoteChar = (quoteCharacter == null) ? CSVWriter.NO_QUOTE_CHARACTER : quoteCharacter.charAt(0);
try (CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(this.fileNameReportExtensionConcept,
!addHeader), // append
CharEncoding.UTF_8),
Check.getOutputFileContentSeparator(),
quoteChar,
System.lineSeparator())) {
// header
if (addHeader) {
writer.writeNext(REPORT_HEADER);
log.info("Created {}", this.fileNameReportExtensionConcept);
}
// content
writer.writeNext(new String[] {
conceptId,
fullySpecifiedName
});
writer.flush();
}
}
示例12: createPostMethod
public static HttpPost createPostMethod(URI uri, String body) {
if(uri == null) return null;
HttpPost method = new HttpPost(uri);
setHeader(method);
configProxy(method);
StringEntity entity = new StringEntity(body, CharEncoding.UTF_8);
method.setEntity(entity);
return method;
}
示例13: createPutMethod
public static HttpPut createPutMethod(URI uri, String body) {
if(uri == null) return null;
HttpPut method = new HttpPut(uri);
setHeader(method);
configProxy(method);
StringEntity entity = new StringEntity(body, CharEncoding.UTF_8);
method.setEntity(entity);
return method;
}
示例14: getEntity
@Override
public HttpEntity getEntity() throws BoxRestException {
try {
return new StringEntity(getJSONEntity().toJSONString(objectMapper), CharEncoding.UTF_8);
}
catch (Exception e) {
throw new BoxRestException(e);
}
}
示例15: URLCodec
/**
* Default constructor.
*/
public URLCodec() {
this(CharEncoding.UTF_8);
}