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


Java CharsetUtil.UTF_8属性代码示例

本文整理汇总了Java中io.netty.util.CharsetUtil.UTF_8属性的典型用法代码示例。如果您正苦于以下问题:Java CharsetUtil.UTF_8属性的具体用法?Java CharsetUtil.UTF_8怎么用?Java CharsetUtil.UTF_8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在io.netty.util.CharsetUtil的用法示例。


在下文中一共展示了CharsetUtil.UTF_8属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getParameterMap

/**
 * 获取请求参数的Map
 * @param request
 * @return
 */
public static Map<String, List<String>> getParameterMap(HttpRequest request){
    Map<String, List<String>> paramMap = new HashMap<String, List<String>>();

    HttpMethod method = request.method();
    if(HttpMethod.GET.equals(method)){
        String uri = request.uri();
        QueryStringDecoder queryDecoder = new QueryStringDecoder(uri, CharsetUtil.UTF_8);
        paramMap = queryDecoder.parameters();

    }else if(HttpMethod.POST.equals(method)){
        FullHttpRequest fullRequest = (FullHttpRequest) request;
        paramMap = getPostParamMap(fullRequest);
    }

    return paramMap;
}
 
开发者ID:all4you,项目名称:redant,代码行数:21,代码来源:HttpRequestUtil.java

示例2: dotStuff

private String dotStuff(String testString, int chunkSize) throws Exception {
  ByteArrayInputStream stream = new ByteArrayInputStream(testString.getBytes(StandardCharsets.UTF_8));
  DotStuffingChunkedStream chunkedStream = new DotStuffingChunkedStream(stream, chunkSize);

  CompositeByteBuf destBuffer = ALLOCATOR.compositeBuffer();

  while (!chunkedStream.isEndOfInput()) {
    destBuffer.addComponent(true, chunkedStream.readChunk(ALLOCATOR));
  }

  byte[] bytes = new byte[destBuffer.readableBytes()];
  destBuffer.getBytes(0, bytes);

  ReferenceCountUtil.release(destBuffer);
  return new String(bytes, CharsetUtil.UTF_8);
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:16,代码来源:DotStuffingChunkedStreamTest.java

示例3: encode

public String encode(byte[] bytes) throws Exception {
	// 加密验证
	int zeroFlag = 0;
	byte[] jsonByteFillZero = null;
	int len = bytes.length;
	if ((len & 0XF) != 0) {
		len = ((len >> 4) + 1) << 4;
		zeroFlag = len - bytes.length;
		jsonByteFillZero = new byte[len];
		System.arraycopy(bytes, 0, jsonByteFillZero, 0, bytes.length);
	} else {
		jsonByteFillZero = bytes;
	}
	byte[] doFinal = null;
	Cipher cipher = Cipher.getInstance(TRANSFORMATION);
	cipher.init(Cipher.ENCRYPT_MODE, generateKey, new IvParameterSpec(this.iv));
	doFinal = cipher.doFinal(jsonByteFillZero);
	byte[] content = new byte[doFinal.length + this.iv.length];
	System.arraycopy(this.iv, 0, content, 0, this.iv.length);
	System.arraycopy(doFinal, 0, content, this.iv.length, doFinal.length);
	byte[] base64Encode = SecurityUtil.base64Encode(content);
	String b64Str = new String(base64Encode, CharsetUtil.UTF_8);
	String result = b64Str.replace('+', '-').replace('/', '_').replace('=', '.');
	if (zeroFlag > 0) {
		result = "$" + String.format("%02d", zeroFlag) + result;
	}
	return result;
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:28,代码来源:SymmetricEncryptionUtil.java

示例4: decode

public String decode(String source) throws Exception {
	String tokenSource = source;
	int zeroFlag = 0;
	if (tokenSource.startsWith("$")) {
		zeroFlag = Integer.parseInt(tokenSource.substring(1, 3));
		tokenSource = tokenSource.substring(3);
	}
	String token = tokenSource.replace('-', '+').replace('_', '/').replace('.', '=');
	byte[] base64Decode = SecurityUtil.base64Decode(token.getBytes(CharsetUtil.UTF_8));
	byte[] iv = new byte[0X10];
	byte[] content = new byte[base64Decode.length - iv.length];
	System.arraycopy(base64Decode, 0, iv, 0, iv.length);
	System.arraycopy(base64Decode, iv.length, content, 0, content.length);
	Cipher cipher = Cipher.getInstance(TRANSFORMATION);
	cipher.init(Cipher.DECRYPT_MODE, generateKey, new IvParameterSpec(iv));
	byte[] doFinal = cipher.doFinal(content);
	// 去补零
	int realSize = doFinal.length;
	if (zeroFlag > 0) {
		realSize = doFinal.length - zeroFlag;
		byte[] afterZero = new byte[realSize];
		System.arraycopy(doFinal, 0, afterZero, 0, afterZero.length);
		return new String(afterZero, CharsetUtil.UTF_8);
	} else {
		return new String(doFinal, CharsetUtil.UTF_8);
	}
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:27,代码来源:SymmetricEncryptionUtil.java

示例5: getString

/**
 * 读取String类型
 * 
 * @param buffer
 * @return
 */
protected final String getString() {
	byte[] bytes = getByteArray();
	if (bytes == null) {
		return null;
	} else if (bytes.length == 0) {
		return "";
	} else {
		return new String(bytes, CharsetUtil.UTF_8);
	}
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:16,代码来源:MessageMeta.java

示例6: terminate

private String terminate(String testString, int chunkSize) throws Exception {
  ByteArrayInputStream stream = new ByteArrayInputStream(testString.getBytes(StandardCharsets.UTF_8));
  CrlfTerminatingChunkedStream chunkedStream = new CrlfTerminatingChunkedStream(stream, chunkSize);

  CompositeByteBuf destBuffer = ALLOCATOR.compositeBuffer();
  while (!chunkedStream.isEndOfInput()) {
    destBuffer.addComponent(true, chunkedStream.readChunk(ALLOCATOR));
  }

  byte[] bytes = new byte[destBuffer.readableBytes()];
  destBuffer.getBytes(0, bytes);
  destBuffer.release();
  return new String(bytes, CharsetUtil.UTF_8);
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:14,代码来源:CrlfTerminatingChunkedStreamTest.java

示例7: dotStuffUsingByteBuf

private String dotStuffUsingByteBuf(String testString, boolean atStartOfLine, boolean appendCRLF) {
  ByteBuf sourceBuffer = ALLOCATOR.buffer();
  sourceBuffer.writeBytes(testString.getBytes(StandardCharsets.UTF_8));

  byte[] previousBytes = atStartOfLine ? null : new byte[] { 'x', 'y' };
  ByteBuf destBuffer = DotStuffing.createDotStuffedBuffer(ALLOCATOR, sourceBuffer, previousBytes,
      appendCRLF ? MessageTermination.ADD_CRLF : MessageTermination.DO_NOT_TERMINATE);

  byte[] bytes = new byte[destBuffer.readableBytes()];
  destBuffer.getBytes(0, bytes);
  return new String(bytes, CharsetUtil.UTF_8);
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:12,代码来源:DotStuffingTest.java

示例8: extract

private String extract(Object o) {
  assertThat(o).isInstanceOf(ByteBuf.class);

  ByteBuf buffer = (ByteBuf) o;

  byte[] bytes = new byte[buffer.readableBytes()];
  buffer.getBytes(0, bytes);
  return new String(bytes, CharsetUtil.UTF_8);
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:9,代码来源:ByteBufMessageContentTest.java

示例9: StringCodec

public StringCodec() {
    this(CharsetUtil.UTF_8);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:3,代码来源:StringCodec.java

示例10: base64Encode2

public static String base64Encode2(String stringsrc) throws UnsupportedEncodingException {
	return new String(base64Encode(stringsrc.getBytes(CharsetUtil.UTF_8)), CharsetUtil.UTF_8);
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:3,代码来源:SecurityUtil.java

示例11: NetoMessageToJsonEncoder

public NetoMessageToJsonEncoder() {
    this(CharsetUtil.UTF_8);
}
 
开发者ID:veritasware,项目名称:neto,代码行数:3,代码来源:NetoMessageToJsonEncoder.java

示例12: contentToString

public String contentToString(){
    return new String(this.content, CharsetUtil.UTF_8);
}
 
开发者ID:dovakinlink,项目名称:netty-dovakin-android-client,代码行数:3,代码来源:NGLSProtocol.java

示例13: willMessage

/**
 * @deprecated use {@link MqttConnectPayload#willMessageInBytes()} instead
 */
@Deprecated
public String willMessage() {
    return willMessage == null ? null : new String(willMessage, CharsetUtil.UTF_8);
}
 
开发者ID:Dovakin-IO,项目名称:DovakinMQ,代码行数:7,代码来源:MqttConnectPayload.java

示例14: password

/**
 * @deprecated use {@link MqttConnectPayload#passwordInBytes()} instead
 */
@Deprecated
public String password() {
    return password == null ? null : new String(password, CharsetUtil.UTF_8);
}
 
开发者ID:Dovakin-IO,项目名称:DovakinMQ,代码行数:7,代码来源:MqttConnectPayload.java

示例15: getEncoder

/**
 * Returns StringEncoder of UTF_8 .
 * @return StringEncoder
 */
public static StringEncoder getEncoder() {
    return new StringEncoder(CharsetUtil.UTF_8);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:StringEncoderUtil.java


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