本文整理了Java中org.apache.commons.codec.binary.Hex.<init>()
方法的一些代码示例,展示了Hex.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hex.<init>()
方法的具体详情如下:
包路径:org.apache.commons.codec.binary.Hex
类名称:Hex
方法名:<init>
[英]Creates a new codec with the default charset name #DEFAULT_CHARSET
[中]使用默认字符集名称#default#u字符集创建新的编解码器
代码示例来源:origin: commons-codec/commons-codec
@Test(expected = UnsupportedCharsetException.class)
public void testCustomCharsetBadName() {
new Hex(BAD_ENCODING_NAME);
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeHexByteBufferEmpty() {
assertTrue(Arrays.equals(new char[0], Hex.encodeHex(ByteBuffer.allocate(0))));
assertTrue(Arrays.equals(new byte[0], new Hex().encode(ByteBuffer.allocate(0))));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeByteBufferOddCharacters() {
final ByteBuffer buffer = ByteBuffer.allocate(1);
buffer.put((byte) 65);
try {
new Hex().decode(buffer);
fail("An exception wasn't thrown when trying to decode an odd number of characters");
} catch (final DecoderException e) {
// Expected exception
}
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeByteBufferEmpty() {
assertTrue(Arrays.equals(new byte[0], new Hex().encode(ByteBuffer.allocate(0))));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeByteBufferObjectEmpty() throws EncoderException {
assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode((Object) ByteBuffer.allocate(0))));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeHexByteArrayEmpty() {
assertTrue(Arrays.equals(new char[0], Hex.encodeHex(new byte[0])));
assertTrue(Arrays.equals(new byte[0], new Hex().encode(new byte[0])));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testCustomCharsetToString() {
assertTrue(new Hex().toString().indexOf(Hex.DEFAULT_CHARSET_NAME) >= 0);
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeByteArrayEmpty() {
assertTrue(Arrays.equals(new byte[0], new Hex().encode(new byte[0])));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeByteArrayObjectEmpty() throws EncoderException {
assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode((Object) new byte[0])));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeByteArrayObjectEmpty() throws DecoderException {
assertTrue(Arrays.equals(new byte[0], (byte[]) new Hex().decode((Object) new byte[0])));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeStringEmpty() throws DecoderException {
assertTrue(Arrays.equals(new byte[0], (byte[]) new Hex().decode("")));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testGetCharsetName() {
Assert.assertEquals(Charsets.UTF_8.name(), new Hex(Charsets.UTF_8).getCharsetName());
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeStringEmpty() throws EncoderException {
assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode("")));
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeBadCharacterPos1() {
try {
new Hex().decode("0q");
fail("An exception wasn't thrown when trying to decode an illegal character");
} catch (final DecoderException e) {
// Expected exception
}
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeBadCharacterPos0() {
try {
new Hex().decode("q0");
fail("An exception wasn't thrown when trying to decode an illegal character");
} catch (final DecoderException e) {
// Expected exception
}
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testEncodeClassCastException() {
try {
new Hex().encode(new int[] { 65 });
fail("An exception wasn't thrown when trying to encode.");
} catch (final EncoderException e) {
// Expected exception
}
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeClassCastException() {
try {
new Hex().decode(new int[] { 65 });
fail("An exception wasn't thrown when trying to decode.");
} catch (final DecoderException e) {
// Expected exception
}
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeHexStringOddCharacters() {
try {
new Hex().decode("6");
fail("An exception wasn't thrown when trying to decode an odd number of characters");
} catch (final DecoderException e) {
// Expected exception
}
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testDecodeByteArrayOddCharacters() {
try {
new Hex().decode(new byte[] { 65 });
fail("An exception wasn't thrown when trying to decode an odd number of characters");
} catch (final DecoderException e) {
// Expected exception
}
}
代码示例来源:origin: commons-codec/commons-codec
@Test
public void testGetCharset() {
Assert.assertEquals(Charsets.UTF_8, new Hex(Charsets.UTF_8).getCharset());
}
内容来源于网络,如有侵权,请联系作者删除!