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


Java CharacterCodingException.getMessage方法代码示例

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


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

示例1: decode

import java.nio.charset.CharacterCodingException; //导入方法依赖的package包/类
public static void decode(CharsetDecoder charsetDecoder, ByteBuffer byteBuf, CharBuffer charByte) {
    try {
        CoderResult cr = charsetDecoder.decode(byteBuf, charByte, true);

        if (!cr.isUnderflow()) {
            cr.throwException();
        }

        cr = charsetDecoder.flush(charByte);

        if (!cr.isUnderflow()) {
            cr.throwException();
        }
    } catch (CharacterCodingException x) {
        // Substitution is always enabled,
        // so this shouldn't happen
        throw new JSONException("utf8 decode error, " + x.getMessage(), x);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:IOUtils.java

示例2: encode

import java.nio.charset.CharacterCodingException; //导入方法依赖的package包/类
public byte[] encode(char[] chars, int off, int len, byte[] bytes) {
    ByteBuffer byteBuf = ByteBuffer.wrap(bytes);
    try {
        CoderResult cr = this.encoder.encode(CharBuffer.wrap(chars, off, len), byteBuf, true);
        if (!cr.isUnderflow()) {
            cr.throwException();
        }
        cr = this.encoder.flush(byteBuf);
        if (!cr.isUnderflow()) {
            cr.throwException();
        }
        int bytesLength = byteBuf.position();
        byte[] copy = new byte[bytesLength];
        System.arraycopy(bytes, 0, copy, 0, bytesLength);
        return copy;
    } catch (CharacterCodingException x) {
        throw new JSONException(x.getMessage(), x);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:SerialWriterStringEncoder.java

示例3: encode

import java.nio.charset.CharacterCodingException; //导入方法依赖的package包/类
public byte[] encode(char[] chars, int off, int len, byte[] bytes) {
	ByteBuffer byteBuf = ByteBuffer.wrap(bytes);

	CharBuffer charBuf = CharBuffer.wrap(chars, off, len);
	try {
		CoderResult cr = encoder.encode(charBuf, byteBuf, true);
		if (!cr.isUnderflow()) {
			cr.throwException();
		}
		cr = encoder.flush(byteBuf);
		if (!cr.isUnderflow()) {
			cr.throwException();
		}
	} catch (CharacterCodingException x) {
		// Substitution is always enabled,
		// so this shouldn't happen
		throw new JSONException(x.getMessage(), x);
	}

	int bytesLength = byteBuf.position();
	byte[] copy = new byte[bytesLength];
	System.arraycopy(bytes, 0, copy, 0, bytesLength);
	return copy;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:25,代码来源:SerialWriterStringEncoder.java

示例4: decode

import java.nio.charset.CharacterCodingException; //导入方法依赖的package包/类
public static void decode(CharsetDecoder charsetDecoder, ByteBuffer byteBuf, CharBuffer charByte) {
    try {
        CoderResult cr = charsetDecoder.decode(byteBuf, charByte, true);

        if (!cr.isUnderflow()) {
            cr.throwException();
        }

        cr = charsetDecoder.flush(charByte);

        if (!cr.isUnderflow()) {
            cr.throwException();
        }
    } catch (CharacterCodingException x) {
        // Substitution is always enabled,
        // so this shouldn't happen
        throw new JSONException(x.getMessage(), x);
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:20,代码来源:IOUtils.java

示例5: scanUriEscapes

import java.nio.charset.CharacterCodingException; //导入方法依赖的package包/类
/**
 * <p>
 * Scan a sequence of %-escaped URI escape codes and convert them into a
 * String representing the unescaped values.
 * </p>
 * 
 * FIXME This method fails for more than 256 bytes' worth of URI-encoded
 * characters in a row. Is this possible? Is this a use-case?
 * 
 * @see <a href="http://www.ietf.org/rfc/rfc2396.txt"></a>, section 2.4, Escaped Encoding.
 */
private String scanUriEscapes(String name, Mark startMark) {
    // First, look ahead to see how many URI-escaped characters we should
    // expect, so we can use the correct buffer size.
    int length = 1;
    while (reader.peek(length * 3) == '%') {
        length++;
    }
    // See the specification for details.
    // URIs containing 16 and 32 bit Unicode characters are
    // encoded in UTF-8, and then each octet is written as a
    // separate character.
    Mark beginningMark = reader.getMark();
    ByteBuffer buff = ByteBuffer.allocate(length);
    while (reader.peek() == '%') {
        reader.forward();
        try {
            byte code = (byte) Integer.parseInt(reader.prefix(2), 16);
            buff.put(code);
        } catch (NumberFormatException nfe) {
            throw new ScannerException("while scanning a " + name, startMark,
                    "expected URI escape sequence of 2 hexadecimal numbers, but found "
                            + reader.peek() + "(" + ((int) reader.peek()) + ") and "
                            + reader.peek(1) + "(" + ((int) reader.peek(1)) + ")",
                    reader.getMark());
        }
        reader.forward(2);
    }
    buff.flip();
    try {
        return UriEncoder.decode(buff);
    } catch (CharacterCodingException e) {
        throw new ScannerException("while scanning a " + name, startMark,
                "expected URI in UTF-8: " + e.getMessage(), beginningMark);
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:47,代码来源:ScannerImpl.java

示例6: scanUriEscapes

import java.nio.charset.CharacterCodingException; //导入方法依赖的package包/类
/**
 * <p>
 * Scan a sequence of %-escaped URI escape codes and convert them into a
 * String representing the unescaped values.
 * </p>
 * 
 * FIXME This method fails for more than 256 bytes' worth of URI-encoded
 * characters in a row. Is this possible? Is this a use-case?
 * 
 * @see <a href="http://www.ietf.org/rfc/rfc2396.txt"></a>, section 2.4, Escaped Encoding.
 */
private String scanUriEscapes(String name, Mark startMark) {
    // First, look ahead to see how many URI-escaped characters we should
    // expect, so we can use the correct buffer size.
    int length = 1;
    while (reader.peek(length * 3) == '%') {
        length++;
    }
    // See the specification for details.
    // URIs containing 16 and 32 bit Unicode characters are
    // encoded in UTF-8, and then each octet is written as a
    // separate character.
    Mark beginningMark = reader.getMark();
    ByteBuffer buff = ByteBuffer.allocate(length);
    while (reader.peek() == '%') {
        reader.forward();
        try {
            byte code = (byte) Integer.parseInt(reader.prefix(2), 16);
            buff.put(code);
        } catch (NumberFormatException nfe) {
            int c1 = reader.peek();
            final String s1 = String.valueOf(Character.toChars(c1));
            int c2 = reader.peek(1);
            final String s2 = String.valueOf(Character.toChars(c2));
            throw new ScannerException("while scanning a " + name, startMark,
                    "expected URI escape sequence of 2 hexadecimal numbers, but found "
                            + s1 + "(" + c1 + ") and "
                            + s2 + "(" + c2 + ")",
                    reader.getMark());
        }
        reader.forward(2);
    }
    buff.flip();
    try {
        return UriEncoder.decode(buff);
    } catch (CharacterCodingException e) {
        throw new ScannerException("while scanning a " + name, startMark,
                "expected URI in UTF-8: " + e.getMessage(), beginningMark);
    }
}
 
开发者ID:RoccoDev,项目名称:5zig-TIMV-Plugin,代码行数:51,代码来源:ScannerImpl.java

示例7: decode

import java.nio.charset.CharacterCodingException; //导入方法依赖的package包/类
public static void decode(CharsetDecoder charsetDecoder, ByteBuffer byteBuf, CharBuffer charByte) {
    try {
        CoderResult cr = charsetDecoder.decode(byteBuf, charByte, true);
        if (!cr.isUnderflow()) {
            cr.throwException();
        }
        cr = charsetDecoder.flush(charByte);
        if (!cr.isUnderflow()) {
            cr.throwException();
        }
    } catch (CharacterCodingException x) {
        throw new JSONException(x.getMessage(), x);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:IOUtils.java


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