List of usage examples for java.nio.charset StandardCharsets UTF_8
Charset UTF_8
To view the source code for java.nio.charset StandardCharsets UTF_8.
Click Source Link
From source file:name.martingeisse.servlet_httpclient.sidekicks.fakecdn.FakeCdn.java
/** * Requests an entity from the CDN. If the entity is not yet stored, * it is fetched. The response is stored, whether it is a successful * or failed response; only redirect-responses are resolved by another * request. If fetching the entity fails so hard that no response is * even available (e.g. server not reached), a fake 404 response is * built./*from w w w .j a v a2 s . co m*/ * * @param key the storage key * @return the record for the entity */ public FakeCdnRecord request(String key) { FakeCdnRecord record = cache.get(key); if (record == null) { try { record = fetch(key); } catch (IOException e) { record = new FakeCdnRecord(404, key, "text/plain; charset=UTF-8", "could not connect to server".getBytes(StandardCharsets.UTF_8)); } cache.put(key, record); } return record; }
From source file:com.haulmont.cuba.core.sys.PasswordEncryptionImpl.java
@Override public String generateRandomPassword() { SecureRandom random;// www . j a v a 2 s .c om try { random = SecureRandom.getInstance("SHA1PRNG"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("Unable to load SHA1PRNG", e); } byte[] passwordBytes = new byte[6]; random.nextBytes(passwordBytes); return new String(Base64.encodeBase64(passwordBytes), StandardCharsets.UTF_8).replace("=", ""); }
From source file:io.kamax.mxisd.controller.profile.v1.ProfileInternalController.java
@RequestMapping(method = GET, path = "/_matrix-internal/profile/v1/{userId:.+}") public String getProfile(@PathVariable String userId) throws UnsupportedEncodingException { userId = URLDecoder.decode(userId, StandardCharsets.UTF_8.name()); _MatrixID mxId = MatrixID.asAcceptable(userId); return GsonUtil.get().toJson(GsonUtil.makeObj("roles", GsonUtil.asArray(mgr.getRoles(mxId)))); }
From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemObisCodeDto.java
public CosemObisCodeDto(final byte[] code) { if (code.length == 6) { this.a = code[0] & 0xFF; this.b = code[1] & 0xFF; this.c = code[2] & 0xFF; this.d = code[3] & 0xFF; this.e = code[4] & 0xFF; this.f = code[5] & 0xFF; } else {/*from ww w . j av a 2 s . c om*/ final String logicalName = new String(code, StandardCharsets.UTF_8); final String tags[] = StringUtils.split(logicalName, '.'); this.a = Integer.parseInt(tags[0]); this.b = Integer.parseInt(tags[1]); this.c = Integer.parseInt(tags[2]); this.d = Integer.parseInt(tags[3]); this.e = Integer.parseInt(tags[4]); this.f = Integer.parseInt(tags[5]); } }
From source file:com.romeikat.datamessie.core.base.util.StringUtil.java
public String removeLineSeparators(final String s) { if (s == null) { return null; }/*from w w w . j a v a 2 s.co m*/ try { final StringBuilder sb = new StringBuilder(); final InputStream is = IOUtils.toInputStream(s, StandardCharsets.UTF_8); final LineIterator it = IOUtils.lineIterator(is, StandardCharsets.UTF_8); while (it.hasNext()) { if (sb.length() > 0) { sb.append(" "); } sb.append(it.nextLine()); } IOUtils.closeQuietly(is); return sb.toString(); } catch (final IOException e) { e.printStackTrace(); return null; } }
From source file:jenkins.security.ClassFilterImplSanityTest.java
@Test public void whitelistSanity() throws Exception { try (InputStream is = ClassFilterImpl.class.getResourceAsStream("whitelisted-classes.txt")) { List<String> lines = IOUtils.readLines(is, StandardCharsets.UTF_8).stream() .filter(line -> !line.matches("#.*|\\s*")).collect(Collectors.toList()); assertThat("whitelist is NOT ordered", new TreeSet<>(lines), contains(lines.toArray(MemoryReductionUtil.EMPTY_STRING_ARRAY))); for (String line : lines) { try { Class.forName(line); } catch (ClassNotFoundException x) { System.err.println("skipping checks of unknown class " + line); }//from www .ja v a 2 s . c o m } } }
From source file:org.elasticsearch.test.rest.client.RestTestResponse.java
public RestTestResponse(Response response) throws IOException { this.response = response; if (response.getEntity() != null) { try {/*from w w w . j av a 2 s . co m*/ this.body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); } catch (IOException e) { EntityUtils.consumeQuietly(response.getEntity()); throw new RuntimeException(e); } finally { IOUtils.closeWhileHandlingException(response); } } else { this.body = null; } parseResponseBody(); }
From source file:net.sf.jabref.logic.journals.AbbreviationParser.java
public void readJournalListFromResource(String resourceFileName) { URL url = Objects.requireNonNull( JournalAbbreviationRepository.class.getResource(Objects.requireNonNull(resourceFileName))); try {/*from w w w . jav a 2 s . c o m*/ readJournalList(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8)); } catch (IOException e) { LOGGER.info("Could not read journal list from file " + resourceFileName, e); } }
From source file:app.data.model.Link.java
@JsonCreator public Link(@JsonProperty(value = "url") String url, @JsonProperty(value = "title") String title) { this.url = url; this.title = title; // 1/(0.5% * 0.5%)? 50 ???? this.urlUnique = Hashing.murmur3_128().hashString(url, StandardCharsets.UTF_8).toString() + Hashing.sipHash24().hashString(url, StandardCharsets.UTF_8); }
From source file:name.martingeisse.trading_game.platform.util.logging.MyLayout.java
/** * Constructor.//from w ww.ja v a 2 s. c om * * @param useParagraphSeparator whether to use a paragraph separator */ public MyLayout(boolean useParagraphSeparator) { super(StandardCharsets.UTF_8); this.useParagraphSeparator = useParagraphSeparator; instanceSource = new Exception(); }