本文整理了Java中java.nio.charset.CoderResult.isOverflow()
方法的一些代码示例,展示了CoderResult.isOverflow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CoderResult.isOverflow()
方法的具体详情如下:
包路径:java.nio.charset.CoderResult
类名称:CoderResult
方法名:isOverflow
[英]Returns true if this result is an overflow condition.
[中]如果此结果是溢出条件,则返回true。
代码示例来源:origin: commons-io/commons-io
/**
* Decode the contents of the input ByteBuffer into a CharBuffer.
*
* @param endOfInput indicates end of input
* @throws IOException if an I/O error occurs
*/
private void processInput(final boolean endOfInput) throws IOException {
// Prepare decoderIn for reading
decoderIn.flip();
CoderResult coderResult;
while (true) {
coderResult = decoder.decode(decoderIn, decoderOut, endOfInput);
if (coderResult.isOverflow()) {
flushOutput();
} else if (coderResult.isUnderflow()) {
break;
} else {
// The decoder is configured to replace malformed input and unmappable characters,
// so we should not get here.
throw new IOException("Unexpected coder result");
}
}
// Discard the bytes that have been read
decoderIn.compact();
}
代码示例来源:origin: robovm/robovm
private void convert(CharBuffer chars) throws IOException {
while (true) {
CoderResult result = encoder.encode(chars, bytes, false);
if (result.isOverflow()) {
// Make room and try again.
flushBytes(false);
continue;
} else if (result.isError()) {
result.throwException();
}
break;
}
}
代码示例来源:origin: robovm/robovm
private void drainEncoder() throws IOException {
// Strictly speaking, I think it's part of the CharsetEncoder contract that you call
// encode with endOfInput true before flushing. Our ICU-based implementations don't
// actually need this, and you'd hope that any reasonable implementation wouldn't either.
// CharsetEncoder.encode doesn't actually pass the boolean through to encodeLoop anyway!
CharBuffer chars = CharBuffer.allocate(0);
while (true) {
CoderResult result = encoder.encode(chars, bytes, true);
if (result.isError()) {
result.throwException();
} else if (result.isOverflow()) {
flushBytes(false);
continue;
}
break;
}
// Some encoders (such as ISO-2022-JP) have stuff to write out after all the
// characters (such as shifting back into a default state). In our implementation,
// this is actually the first time ICU is told that we've run out of input.
CoderResult result = encoder.flush(bytes);
while (!result.isUnderflow()) {
if (result.isOverflow()) {
flushBytes(false);
result = encoder.flush(bytes);
} else {
result.throwException();
}
}
}
代码示例来源:origin: spring-projects/spring-framework
CoderResult cr = (inBuffer.hasRemaining() ?
charsetEncoder.encode(inBuffer, outBuffer, true) : CoderResult.UNDERFLOW);
if (cr.isUnderflow()) {
cr = charsetEncoder.flush(outBuffer);
if (cr.isUnderflow()) {
break;
if (cr.isOverflow()) {
writePosition(outBuffer.position());
int maximumSize = (int) (inBuffer.remaining() * charsetEncoder.maxBytesPerChar());
代码示例来源:origin: google/guava
if (result.isOverflow()) {
} else if (result.isUnderflow()) {
readMoreChars();
} else if (result.isError()) {
代码示例来源:origin: android-hacker/VirtualXposed
public void flush() throws IOException {
//Log.i("PackageManager", "flush mPos=" + mPos);
if (mPos > 0) {
if (mOutputStream != null) {
CharBuffer charBuffer = CharBuffer.wrap(mText, 0, mPos);
CoderResult result = mCharset.encode(charBuffer, mBytes, true);
while (true) {
if (result.isError()) {
throw new IOException(result.toString());
} else if (result.isOverflow()) {
flushBytes();
result = mCharset.encode(charBuffer, mBytes, true);
continue;
}
break;
}
flushBytes();
mOutputStream.flush();
} else {
mWriter.write(mText, 0, mPos);
mWriter.flush();
}
mPos = 0;
}
}
代码示例来源:origin: org.apache.ant/ant
} else if (res.isOverflow()) {
} else if (res.isUnderflow()) {
代码示例来源:origin: wildfly/wildfly
while (byteBuffer.hasRemaining()) {
final CoderResult result = decoder.decode(byteBuffer, charBuffer, eof);
if (result.isOverflow()) {
writer.write(chars, 0, charBuffer.position());
charBuffer.clear();
continue;
if (result.isUnderflow()) {
final int p = charBuffer.position();
if (p > 0) {
if (result.isError()) {
if (result.isMalformed()) {
throw msg.malformedInput();
代码示例来源:origin: evernote/android-job
public void flush() throws IOException {
//Log.i("PackageManager", "flush mPos=" + mPos);
if (mPos > 0) {
if (mOutputStream != null) {
CharBuffer charBuffer = CharBuffer.wrap(mText, 0, mPos);
CoderResult result = mCharset.encode(charBuffer, mBytes, true);
while (true) {
if (result.isError()) {
throw new IOException(result.toString());
} else if (result.isOverflow()) {
flushBytes();
result = mCharset.encode(charBuffer, mBytes, true);
continue;
}
break;
}
flushBytes();
mOutputStream.flush();
} else {
mWriter.write(mText, 0, mPos);
mWriter.flush();
}
mPos = 0;
}
}
代码示例来源:origin: apache/ignite
CoderResult res = charsetDecoder.decode(dataBuf, outBuf, isEndOfInput);
if (res.isUnderflow()) {
if (res.isOverflow()) {
assert outBuf.position() > 0;
代码示例来源:origin: prestodb/presto
if (result.isOverflow()) {
} else if (result.isUnderflow()) {
readMoreChars();
} else if (result.isError()) {
代码示例来源:origin: nu.zoom.svansprogram/svansprogram-tail
private void logErrors(CoderResult coderResult) {
if (coderResult.isOverflow()) {
log.error("Buffer overflow, the character buffer is not large enough to decode the characters, some information may be lost");
} else if (coderResult.isError()) {
log.warn("There was some error in decoding the file given the current charset");
}
}
代码示例来源:origin: alibaba/mdrill
} else if (res.isOverflow()) {
} else if (res.isUnderflow()) {
代码示例来源:origin: google/j2objc
if (result.isOverflow()) {
} else if (result.isUnderflow()) {
readMoreChars();
} else if (result.isError()) {
代码示例来源:origin: com.palominolabs.http/url-builder
private static void checkResult(CoderResult result) throws CharacterCodingException {
if (result.isOverflow()) {
throw new IllegalStateException("Somehow got byte buffer overflow");
}
if (result.isError()) {
result.throwException();
}
}
代码示例来源:origin: org.springframework/spring-core
CoderResult cr = (inBuffer.hasRemaining() ?
charsetEncoder.encode(inBuffer, outBuffer, true) : CoderResult.UNDERFLOW);
if (cr.isUnderflow()) {
cr = charsetEncoder.flush(outBuffer);
if (cr.isUnderflow()) {
break;
if (cr.isOverflow()) {
writePosition(outBuffer.position());
int maximumSize = (int) (inBuffer.remaining() * charsetEncoder.maxBytesPerChar());
代码示例来源:origin: wildfly/wildfly
while (charBuffer.hasRemaining()) {
final CoderResult result = encoder.encode(charBuffer, byteBuffer, false);
if (result.isOverflow()) {
return true;
if (result.isUnderflow()) {
filled = true;
break;
if (result.isError()) {
if (result.isMalformed()) {
throw msg.malformedInput();
代码示例来源:origin: MobiVM/robovm
private void convert(CharBuffer chars) throws IOException {
while (true) {
CoderResult result = encoder.encode(chars, bytes, false);
if (result.isOverflow()) {
// Make room and try again.
flushBytes(false);
continue;
} else if (result.isError()) {
result.throwException();
}
break;
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private void append(String str) throws CharacterCodingException {
int n = str.length();
if (n > chArr.length) {
chArr = new char[n + 256];
chBuf = CharBuffer.wrap(chArr);
}
str.getChars(0, n, chArr, 0);
chBuf.position(0).limit(n);
utf8.reset();
for (;;) {
CoderResult cr = utf8.encode(chBuf, binBuf, true);
if (cr.isOverflow()) {
grow();
} else if (cr.isUnderflow()) {
break;
} else {
cr.throwException();
}
}
}
代码示例来源:origin: wildfly/wildfly
if (result.isOverflow()) {
} else if (result.isUnderflow()) {
readMoreChars();
} else if (result.isError()) {
内容来源于网络,如有侵权,请联系作者删除!