List of usage examples for org.apache.commons.lang CharEncoding UTF_8
String UTF_8
To view the source code for org.apache.commons.lang CharEncoding UTF_8.
Click Source Link
Eight-bit Unicode Transformation Format.
From source file:com.revitasinc.sonar.dp.batch.parser.StreamGobbler.java
public void run() { BufferedReader br = null;//from ww w . j a v a 2 s .com try { br = new BufferedReader(new InputStreamReader(is, CharEncoding.UTF_8)); String line = null; while ((line = br.readLine()) != null) { if (ERR.equals(type)) { logger.debug(ERR + ">" + line); } else { logger.debug(line); } } } catch (IOException ioe) { logger.error("", ioe); } finally { if (br != null) { try { br.close(); } catch (IOException e) { logger.error("", e); } } logger.debug("StreamGobbler exit for " + type); } }
From source file:eu.eexcess.opensearch.querygenerator.OpensearchQuerygeneratorTest.java
@Test public void toQuery_withSecureUserProfileKeywordsButNoLimit_expectPass() { SecureUserProfile userProfile = new SecureUserProfile(); String keywordText = "some Text with special characters {[]}\\"; userProfile.numResults = 0;// w ww . java2 s . c o m userProfile.contextKeywords = newDummyContextKeywords(7, keywordText); OpensearchQueryGenerator generator = new OpensearchQueryGenerator(); String query = generator.toQuery(userProfile); try { assertTrue(query.contains(URLEncoder.encode(keywordText, CharEncoding.UTF_8))); assertTrue(query.contains(URLEncoder.encode(keywordText + "[1]", CharEncoding.UTF_8))); assertTrue(query.contains(URLEncoder.encode(keywordText + "[6]", CharEncoding.UTF_8))); assertFalse(query.contains(URLEncoder.encode(keywordText + "[7]", CharEncoding.UTF_8))); assertFalse(query.contains("&limit=")); assertFalse(query.contains("limit")); } catch (UnsupportedEncodingException e) { assertTrue(false); } }
From source file:com.fujitsu.dc.common.auth.token.UnitLocalUnitUserToken.java
/** * ?Issuer???IV(Initial Vector)??????./*from w ww. j ava 2 s . co m*/ * IV???issuer?????? ?????Issuer??????? * @param issuer Issuer URL * @return Initial Vector? Byte? */ public static byte[] getIvBytes(final String issuer) { try { return (issuer + "123456789abcdefg").substring(0, IV_BYTE_LENGTH).getBytes(CharEncoding.UTF_8); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
From source file:io.personium.core.model.file.DataCryptorTest.java
/** * Test constructor. Also test getIvBytes(). * normal./*from w w w . java 2 s . co m*/ * @throws Exception Unexpected error. */ @Test public void dataCryptor_Normal() throws Exception { // -------------------- // Test method args // -------------------- String cellId = "zyxwvutsrqponmlkjih"; // -------------------- // Mock settings // -------------------- // Nothing. // -------------------- // Expected result // -------------------- // Nothing. // -------------------- // Run method // -------------------- DataCryptor cryptor = new DataCryptor(cellId); // -------------------- // Confirm result // -------------------- byte[] expected = "hijklmnopqrstuvw".getBytes(CharEncoding.UTF_8); Field field = DataCryptor.class.getDeclaredField("iv"); field.setAccessible(true); byte[] iv = (byte[]) field.get(cryptor); assertThat(iv, is(expected)); }
From source file:it.cineca.pst.huborcid.config.ThymeleafConfiguration.java
@Bean @Description("Spring mail message resolver") public MessageSource emailMessageSource() { log.info("loading non-reloadable mail messages resources"); ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename("classpath:/mails/messages/messages"); messageSource.setDefaultEncoding(CharEncoding.UTF_8); return messageSource; }
From source file:com.iisigroup.cap.utils.CapXmlUtil.java
/** * xml document ? string/* ww w . ja v a 2s .co m*/ * * @param doc * document * @param format * format * @return String */ public static String convertDocumentToString(Document doc, boolean format) { StringWriter out = new StringWriter(); try { new XMLWriter(out, new OutputFormat(Constants.EMPTY_STRING, format, CharEncoding.UTF_8)).write(doc); return out.toString(); } catch (IOException e) { throw new CapMessageException(e, CapXmlUtil.class); } }
From source file:net.sourceforge.fenixedu.util.stork.CanonicalAddressAttribute.java
private void parseAddressCompounds() { try {/*from w w w .j a v a 2 s. c o m*/ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(false); dbf.setValidating(false); DocumentBuilder db; db = dbf.newDocumentBuilder(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( getValue().getBytes(CharEncoding.UTF_8)); Document doc = db.parse(byteArrayInputStream); setFields(doc); } catch (ParserConfigurationException e) { throw new StorkRuntimeException(e); } catch (SAXException e) { throw new StorkRuntimeException(e); } catch (IOException e) { throw new StorkRuntimeException(e); } }
From source file:com.boyuanitsm.fort.service.MailService.java
@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 {//from ww w . jav a 2 s . c o m 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()); } }
From source file:io.personium.core.model.file.DataCryptor.java
/** * Generate IV(Initial Vector) from cell ID.<br> * Use the character string with the last 16 characters reversed. * @param cellId Cell ID/*from ww w . j a va 2 s. c o m*/ * @return Generated IV */ private byte[] createIvBytes(String cellId) { try { // Add 16 characters to the beginning assuming the case of less than 16 characters. return StringUtils.reverse("123456789abcdefg" + cellId).substring(0, IV_BYTE_LENGTH) .getBytes(CharEncoding.UTF_8); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
From source file:com.backelite.sonarqube.swift.issues.tailor.TailorRulesDefinition.java
private void loadRules(final NewRepository repository) throws IOException { Reader reader = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream(RULES_FILE), CharEncoding.UTF_8)); String jsonString = IOUtils.toString(reader); Object rulesObj = JSONValue.parse(jsonString); if (rulesObj != null) { JSONArray slRules = (JSONArray) rulesObj; for (Object obj : slRules) { JSONObject slRule = (JSONObject) obj; RulesDefinition.NewRule rule = repository.createRule((String) slRule.get("key")); rule.setName((String) slRule.get("name")); rule.setSeverity((String) slRule.get("severity")); rule.setHtmlDescription((String) slRule.get("description") + " (<a href=" + (String) slRule.get("styleguide") + ">" + (String) slRule.get("styleguide") + "</a>)"); }/*from w ww . j a v a2 s . c om*/ } }