本文整理了Java中okio.Buffer.readByte()
方法的一些代码示例,展示了Buffer.readByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.readByte()
方法的具体详情如下:
包路径:okio.Buffer
类名称:Buffer
方法名:readByte
暂无
代码示例来源:origin: square/okhttp
/** Returns true if any commas were skipped. */
private static boolean skipWhitespaceAndCommas(Buffer buffer) {
boolean commaFound = false;
while (!buffer.exhausted()) {
byte b = buffer.getByte(0);
if (b == ',') {
buffer.readByte(); // Consume ','.
commaFound = true;
} else if (b == ' ' || b == '\t') {
buffer.readByte(); // Consume space or tab.
} else {
break;
}
}
return commaFound;
}
代码示例来源:origin: square/moshi
@CheckReturnValue public static Options of(String... strings) {
try {
ByteString[] result = new ByteString[strings.length];
Buffer buffer = new Buffer();
for (int i = 0; i < strings.length; i++) {
JsonUtf8Writer.string(buffer, strings[i]);
buffer.readByte(); // Skip the leading double quote (but leave the trailing one).
result[i] = buffer.readByteString();
}
return new Options(strings.clone(), okio.Options.of(result));
} catch (IOException e) {
throw new AssertionError(e);
}
}
}
代码示例来源:origin: square/okhttp
private static void skipName(Buffer in) throws EOFException {
// 0 - 63 bytes
int length = in.readByte();
if (length < 0) {
// compressed name pointer, first two bits are 1
// drop second byte of compression offset
in.skip(1);
} else {
while (length > 0) {
// skip each part of the domain name
in.skip(length);
length = in.readByte();
}
}
}
}
代码示例来源:origin: square/okhttp
private static int skipAll(Buffer buffer, byte b) {
int count = 0;
while (!buffer.exhausted() && buffer.getByte(0) == b) {
count++;
buffer.readByte();
}
return count;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/** Returns true if any commas were skipped. */
private static boolean skipWhitespaceAndCommas(Buffer buffer) {
boolean commaFound = false;
while (!buffer.exhausted()) {
byte b = buffer.getByte(0);
if (b == ',') {
buffer.readByte(); // Consume ','.
commaFound = true;
} else if (b == ' ' || b == '\t') {
buffer.readByte(); // Consume space or tab.
} else {
break;
}
}
return commaFound;
}
代码示例来源:origin: square/okhttp
/**
* Reads a double-quoted string, unescaping quoted pairs like {@code \"} to the 2nd character in
* each sequence. Returns the unescaped string, or null if the buffer isn't prefixed with a
* double-quoted string.
*/
private static String readQuotedString(Buffer buffer) {
if (buffer.readByte() != '\"') throw new IllegalArgumentException();
Buffer result = new Buffer();
while (true) {
long i = buffer.indexOfElement(QUOTED_STRING_DELIMITERS);
if (i == -1L) return null; // Unterminated quoted string.
if (buffer.getByte(i) == '"') {
result.write(buffer, i);
buffer.readByte(); // Consume '"'.
return result.readUtf8();
}
if (buffer.size() == i + 1L) return null; // Dangling escape.
result.write(buffer, i);
buffer.readByte(); // Consume '\'.
result.write(buffer, 1L); // The escaped character.
}
}
代码示例来源:origin: apollographql/apollo-android
/**
* @param toFind a string to search for. Must not contain a newline.
*/
private boolean skipTo(String toFind) throws IOException {
outer:
for (; source.request(toFind.length());) {
for (int c = 0; c < toFind.length(); c++) {
if (buffer.getByte(c) != toFind.charAt(c)) {
buffer.readByte();
continue outer;
}
}
return true;
}
return false;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
private static int skipAll(Buffer buffer, byte b) {
int count = 0;
while (!buffer.exhausted() && buffer.getByte(0) == b) {
count++;
buffer.readByte();
}
return count;
}
代码示例来源:origin: square/retrofit
private static void canonicalizeForPath(Buffer out, String input, int pos, int limit,
boolean alreadyEncoded) {
Buffer utf8Buffer = null; // Lazily allocated.
int codePoint;
for (int i = pos; i < limit; i += Character.charCount(codePoint)) {
codePoint = input.codePointAt(i);
if (alreadyEncoded
&& (codePoint == '\t' || codePoint == '\n' || codePoint == '\f' || codePoint == '\r')) {
// Skip this character.
} else if (codePoint < 0x20 || codePoint >= 0x7f
|| PATH_SEGMENT_ALWAYS_ENCODE_SET.indexOf(codePoint) != -1
|| (!alreadyEncoded && (codePoint == '/' || codePoint == '%'))) {
// Percent encode this character.
if (utf8Buffer == null) {
utf8Buffer = new Buffer();
}
utf8Buffer.writeUtf8CodePoint(codePoint);
while (!utf8Buffer.exhausted()) {
int b = utf8Buffer.readByte() & 0xff;
out.writeByte('%');
out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]);
out.writeByte(HEX_DIGITS[b & 0xf]);
}
} else {
// This character doesn't need encoding. Just copy it over.
out.writeUtf8CodePoint(codePoint);
}
}
}
代码示例来源:origin: square/okhttp
int b = encodedCharBuffer.readByte() & 0xff;
out.writeByte('%');
out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]);
代码示例来源:origin: square/moshi
if (builder == null) builder = new StringBuilder();
builder.append(buffer.readUtf8(index));
buffer.readByte(); // '\'
builder.append(readEscapeCharacter());
continue;
buffer.readByte(); // Consume the quote character.
return result;
} else {
builder.append(buffer.readUtf8(index));
buffer.readByte(); // Consume the quote character.
return builder.toString();
代码示例来源:origin: com.squareup.okhttp3/okhttp
/**
* Reads a double-quoted string, unescaping quoted pairs like {@code \"} to the 2nd character in
* each sequence. Returns the unescaped string, or null if the buffer isn't prefixed with a
* double-quoted string.
*/
private static String readQuotedString(Buffer buffer) {
if (buffer.readByte() != '\"') throw new IllegalArgumentException();
Buffer result = new Buffer();
while (true) {
long i = buffer.indexOfElement(QUOTED_STRING_DELIMITERS);
if (i == -1L) return null; // Unterminated quoted string.
if (buffer.getByte(i) == '"') {
result.write(buffer, i);
buffer.readByte(); // Consume '"'.
return result.readUtf8();
}
if (buffer.size() == i + 1L) return null; // Dangling escape.
result.write(buffer, i);
buffer.readByte(); // Consume '\'.
result.write(buffer, 1L); // The escaped character.
}
}
代码示例来源:origin: apollographql/apollo-android
if (builder == null) builder = new StringBuilder();
builder.append(buffer.readUtf8(index));
buffer.readByte(); // '\'
builder.append(readEscapeCharacter());
continue;
buffer.readByte(); // Consume the quote character.
return result;
} else {
builder.append(buffer.readUtf8(index));
buffer.readByte(); // Consume the quote character.
return builder.toString();
代码示例来源:origin: com.squareup.retrofit2/retrofit
private static void canonicalizeForPath(Buffer out, String input, int pos, int limit,
boolean alreadyEncoded) {
Buffer utf8Buffer = null; // Lazily allocated.
int codePoint;
for (int i = pos; i < limit; i += Character.charCount(codePoint)) {
codePoint = input.codePointAt(i);
if (alreadyEncoded
&& (codePoint == '\t' || codePoint == '\n' || codePoint == '\f' || codePoint == '\r')) {
// Skip this character.
} else if (codePoint < 0x20 || codePoint >= 0x7f
|| PATH_SEGMENT_ALWAYS_ENCODE_SET.indexOf(codePoint) != -1
|| (!alreadyEncoded && (codePoint == '/' || codePoint == '%'))) {
// Percent encode this character.
if (utf8Buffer == null) {
utf8Buffer = new Buffer();
}
utf8Buffer.writeUtf8CodePoint(codePoint);
while (!utf8Buffer.exhausted()) {
int b = utf8Buffer.readByte() & 0xff;
out.writeByte('%');
out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]);
out.writeByte(HEX_DIGITS[b & 0xf]);
}
} else {
// This character doesn't need encoding. Just copy it over.
out.writeUtf8CodePoint(codePoint);
}
}
}
代码示例来源:origin: square/moshi
case '*':
// skip a /* c-style comment */
buffer.readByte(); // '/'
buffer.readByte(); // '*'
if (!skipToEndOfBlockComment()) {
throw syntaxError("Unterminated comment");
buffer.readByte(); // '/'
buffer.readByte(); // '/'
skipToEndOfLine();
p = 0;
代码示例来源:origin: airbnb/DeepLinkDispatch
int b = utf8Buffer.readByte() & 0xff;
out.writeByte('%');
out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]);
代码示例来源:origin: com.squareup.okhttp3/okhttp
int b = encodedCharBuffer.readByte() & 0xff;
out.writeByte('%');
out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]);
代码示例来源:origin: square/moshi
buffer.readByte(); // consume ']' or ','.
switch (c) {
case ']':
buffer.readByte(); // Consume '}' or ','.
switch (c) {
case '}':
switch (c) {
case '"':
buffer.readByte(); // consume the '\"'.
return peeked = PEEKED_DOUBLE_QUOTED_NAME;
case '\'':
buffer.readByte(); // consume the '\''.
checkLenient();
return peeked = PEEKED_SINGLE_QUOTED_NAME;
case '}':
if (peekStack != JsonScope.NONEMPTY_OBJECT) {
buffer.readByte(); // consume the '}'.
return peeked = PEEKED_END_OBJECT;
} else {
buffer.readByte(); // Consume ':'.
switch (c) {
case ':':
checkLenient();
if (source.request(1) && buffer.getByte(0) == '>') {
buffer.readByte(); // Consume '>'.
代码示例来源:origin: square/okio
@Test public void closeEmitsBufferedBytes() throws IOException {
sink.writeByte('a');
sink.close();
assertEquals('a', data.readByte());
}
代码示例来源:origin: square/moshi
byte escaped = buffer.readByte();
switch (escaped) {
case 'u':
内容来源于网络,如有侵权,请联系作者删除!