本文整理匯總了Java中org.apache.commons.codec.Charsets.UTF_8屬性的典型用法代碼示例。如果您正苦於以下問題:Java Charsets.UTF_8屬性的具體用法?Java Charsets.UTF_8怎麽用?Java Charsets.UTF_8使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.commons.codec.Charsets
的用法示例。
在下文中一共展示了Charsets.UTF_8屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: PlayerSkin
public PlayerSkin(UUID uuid){
profile = new GameProfile(uuid, ProfileUtil.getUsername(uuid));
PropertyMap properties = ProfileUtil.getProperties(uuid);
if(properties !=null){
Property textureProperty = Iterables.getFirst(properties.get("textures"), null);
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = null;
MinecraftTexturesPayload result;
try {
String json = new String(Base64.decodeBase64(textureProperty.getValue()), Charsets.UTF_8);
result = gson.fromJson(json, MinecraftTexturesPayload.class);
map = result.getTextures();
} catch (JsonParseException e) {
ModLogger.error("Could not decode textures payload", e);
map = new HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture>();
}
for(Type type : map.keySet()){
Minecraft.getMinecraft().getSkinManager().loadSkin(map.get(type), type, this);
}
}
//playerTextures = downloadPlayerTextures(profile);
}
示例2: toParameter
private Object toParameter(Column col) {
Object value;
if (col instanceof StringColumn){
// use UTF-8 to match open replicator default charset
value = new String((byte[])col.getValue(), Charsets.UTF_8);
} else {
value = col.getValue();
}
if (!(value instanceof java.util.Date)) {
return value;
}
if (value instanceof java.sql.Date || value instanceof java.sql.Timestamp) {
return value;
}
// open replicator sometimes use java.util.Date instead of java.sql.Date.
value = new Timestamp(((java.util.Date)value).getTime());
return value;
}
示例3: handleRequest
public void handleRequest(final RestRequest request, final RestChannel channel) {
String inputStr = new String(request.content().toBytes(), Charsets.UTF_8);
JSONObject input = null;
if (!request.method().equals(GET)) {
input = new JSONObject(inputStr);
}
System.out.println("Path:" + request.path());
if (request.path().equals("/_river/report/now")) {
ESReport esReport = new ESReport(client);
esReport.process(inputStr);
channel.sendResponse(new BytesRestResponse(OK, "{status:finished}"));
}
}
示例4: determineCacheId
private String determineCacheId(ValueSet vs, boolean heirarchical) throws Exception {
// just the content logical definition is hashed
ValueSet vsid = new ValueSet();
vsid.setCompose(vs.getCompose());
JsonParser parser = new JsonParser();
parser.setOutputStyle(OutputStyle.NORMAL);
ByteArrayOutputStream b = new ByteArrayOutputStream();
parser.compose(b, vsid);
b.close();
String s = new String(b.toByteArray(), Charsets.UTF_8);
// any code systems we can find, we add these too.
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
CodeSystem cs = fetchCodeSystem(inc.getSystem());
if (cs != null) {
String css = cacheValue(cs);
s = s + css;
}
}
s = s + "-"+Boolean.toString(heirarchical);
String r = Integer.toString(s.hashCode());
// TextFile.stringToFile(s, Utilities.path(cache, r+".id.json"));
return r;
}
示例5: getMessage
public String getMessage() {
int size = getSize();
byte[] bytes = new byte[size];
for (int i=0; i<size; i++) {
bytes[i] = Unsafe.getByte(this.addr + OFFSET_MESSAGE + i);
}
return new String(bytes, Charsets.UTF_8);
}
示例6: getResultEncoder
/**
* encoder to convert literal result to the client, equivalent to character_set_results
* @return
*/
public Charset getResultEncoder() {
if (this.resultEncoder != null) {
return this.resultEncoder;
}
return (this.parent != null) ? this.parent.getResultEncoder() : Charsets.UTF_8;
}
示例7: getResourceRequestString
public static String getResourceRequestString(String path, String apiKey) throws IOException {
File file = new File(path);
if (!file.exists()) {
//try set /core path
path = "core/" + path;
file = new File(path);
}
InputStream stream = getResourceRequestStream(path);
byte[] b = new byte[(int) file.length()];
int len = b.length;
int total = 0;
while (total < len) {
int result = stream.read(b, total, len - total);
if (result == -1) {
break;
}
total += result;
}
String expected = new String(b, Charsets.UTF_8);
if (apiKey != null && !apiKey.isEmpty()) {
expected = expected.replace("\"AccessToken\":\"+DummyKEY\"",
"\"AccessToken\":\"" + apiKey + "\"");
}
return expected;
}
示例8: hash
/**
* Calculate the SHA-512 message digest hash of the
* provided string and return it with its binary
* data Base64 encoded.
*
* @param string The string to hash
* @return the hashed string Base64 encoded.
*/
public static String hash(final String string) {
try {
final byte[] digest = MessageDigest.getInstance(ALGORITHM).digest((string + SALT).getBytes(Charsets.UTF_8));
return new String(Base64.encodeBase64(digest),Charsets.UTF_8);
} catch (final NoSuchAlgorithmException e) {
throw new AlgorithmNotSupportedException(ALGORITHM, e);
}
}
示例9: parse
@Override
public Supplier<Object> parse(AnnotatedType type, String urlPart) {
Pair<Optional<String>, String> pair = SerializerHelper.parsePrefix(urlPart);
String prefix = pair.getA().get();
if ("null".equals(prefix))
return null;
@SuppressWarnings("rawtypes")
Class<? extends EsEntity> cls = entityClassNumbers.inverse().get(Integer.parseInt(prefix));
String id = new String(BaseEncoding.base64Url().decode(pair.getB()), Charsets.UTF_8);
return () -> {
return es.get(cls, id).orElseThrow(() -> new RuntimeException("Entity not found: " + cls + " id: " + id));
};
}
示例10: loadResource
private static String loadResource(String recordingName) {
try {
URI recURI = WinRmClientRecordedTest.class.getClassLoader().getResource("recordings/" + recordingName + ".xml").toURI();
return new String(Files.readAllBytes(Paths.get(recURI)), Charsets.UTF_8);
} catch (IOException | URISyntaxException e) {
throw new IllegalStateException("Couldn't load recording", e);
}
}
示例11: handleRequest
public void handleRequest(final RestRequest request, final RestChannel channel) {
String inputStr = new String(request.content().toBytes(), Charsets.UTF_8);
if (request.path().equals("/_report")) {
ESReport esReport = new ESReport(client);
esReport.process(inputStr);
channel.sendResponse(new BytesRestResponse(OK, "{status:finished}"));
}
}
示例12: cacheValue
private String cacheValue(CodeSystem cs) throws IOException {
CodeSystem csid = new CodeSystem();
csid.setId(cs.getId());
csid.setVersion(cs.getVersion());
csid.setContent(cs.getContent());
csid.setHierarchyMeaning(CodeSystemHierarchyMeaning.GROUPEDBY);
for (ConceptDefinitionComponent cc : cs.getConcept())
csid.getConcept().add(processCSConcept(cc));
JsonParser parser = new JsonParser();
parser.setOutputStyle(OutputStyle.NORMAL);
ByteArrayOutputStream b = new ByteArrayOutputStream();
parser.compose(b, csid);
b.close();
return new String(b.toByteArray(), Charsets.UTF_8);
}
示例13: QCodec
/**
* Default constructor.
*/
public QCodec() {
this(Charsets.UTF_8);
}
示例14: QuotedPrintableCodec
/**
* Default constructor, assumes default charset of {@link Charsets#UTF_8}
*/
public QuotedPrintableCodec() {
this(Charsets.UTF_8, false);
}
示例15: BCodec
/**
* Default constructor.
*/
public BCodec() {
this(Charsets.UTF_8);
}