okhttp3.internal.Util.checkOffsetAndCount()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(190)

本文整理了Java中okhttp3.internal.Util.checkOffsetAndCount()方法的一些代码示例,展示了Util.checkOffsetAndCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.checkOffsetAndCount()方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:checkOffsetAndCount

Util.checkOffsetAndCount介绍

暂无

代码示例

代码示例来源:origin: square/okhttp

/** Returns a new request body that transmits {@code content}. */
public static RequestBody create(final @Nullable MediaType contentType, final byte[] content,
  final int offset, final int byteCount) {
 if (content == null) throw new NullPointerException("content == null");
 Util.checkOffsetAndCount(content.length, offset, byteCount);
 return new RequestBody() {
  @Override public @Nullable MediaType contentType() {
   return contentType;
  }
  @Override public long contentLength() {
   return byteCount;
  }
  @Override public void writeTo(BufferedSink sink) throws IOException {
   sink.write(content, offset, byteCount);
  }
 };
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/** Returns a new request body that transmits {@code content}. */
public static RequestBody create(final @Nullable MediaType contentType, final byte[] content,
  final int offset, final int byteCount) {
 if (content == null) throw new NullPointerException("content == null");
 Util.checkOffsetAndCount(content.length, offset, byteCount);
 return new RequestBody() {
  @Override public @Nullable MediaType contentType() {
   return contentType;
  }
  @Override public long contentLength() {
   return byteCount;
  }
  @Override public void writeTo(BufferedSink sink) throws IOException {
   sink.write(content, offset, byteCount);
  }
 };
}

代码示例来源:origin: square/okhttp

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (byteCount > bytesRemaining) {
  throw new ProtocolException("expected " + bytesRemaining
    + " bytes but received " + byteCount);
 }
 sink.write(source, byteCount);
 bytesRemaining -= byteCount;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (byteCount > bytesRemaining) {
  throw new ProtocolException("expected " + bytesRemaining
    + " bytes but received " + byteCount);
 }
 sink.write(source, byteCount);
 bytesRemaining -= byteCount;
}

代码示例来源:origin: huxq17/tractor

/** Returns a new request body that transmits {@code content}. */
public static RequestBody create(final MediaType contentType, final byte[] content,
  final int offset, final int byteCount) {
 if (content == null) throw new NullPointerException("content == null");
 Util.checkOffsetAndCount(content.length, offset, byteCount);
 return new RequestBody() {
  @Override public MediaType contentType() {
   return contentType;
  }
  @Override public long contentLength() {
   return byteCount;
  }
  @Override public void writeTo(BufferedSink sink) throws IOException {
   sink.write(content, offset, byteCount);
  }
 };
}

代码示例来源:origin: huxq17/SwipeCardsView

/** Returns a new request body that transmits {@code content}. */
public static RequestBody create(final MediaType contentType, final byte[] content,
  final int offset, final int byteCount) {
 if (content == null) throw new NullPointerException("content == null");
 Util.checkOffsetAndCount(content.length, offset, byteCount);
 return new RequestBody() {
  @Override public MediaType contentType() {
   return contentType;
  }
  @Override public long contentLength() {
   return byteCount;
  }
  @Override public void writeTo(BufferedSink sink) throws IOException {
   sink.write(content, offset, byteCount);
  }
 };
}

代码示例来源:origin: duzechao/OKHttpUtils

/** Returns a new request body that transmits {@code content}. */
public static RequestBody create(final MediaType contentType, final byte[] content,
  final int offset, final int byteCount) {
 if (content == null) throw new NullPointerException("content == null");
 Util.checkOffsetAndCount(content.length, offset, byteCount);
 return new RequestBody() {
  @Override public MediaType contentType() {
   return contentType;
  }
  @Override public long contentLength() {
   return byteCount;
  }
  @Override public void writeTo(BufferedSink sink) throws IOException {
   sink.write(content, offset, byteCount);
  }
 };
}

代码示例来源:origin: com.github.ljun20160606/okhttp

/** Returns a new request body that transmits {@code content}. */
public static RequestBody create(final @Nullable MediaType contentType, final byte[] content,
  final int offset, final int byteCount) {
 if (content == null) throw new NullPointerException("content == null");
 Util.checkOffsetAndCount(content.length, offset, byteCount);
 return new RequestBody() {
  @Override public @Nullable MediaType contentType() {
   return contentType;
  }
  @Override public long contentLength() {
   return byteCount;
  }
  @Override public void writeTo(BufferedSink sink) throws IOException {
   sink.write(content, offset, byteCount);
  }
 };
}

代码示例来源:origin: apache/servicemix-bundles

/** Returns a new request body that transmits {@code content}. */
public static RequestBody create(final @Nullable MediaType contentType, final byte[] content,
  final int offset, final int byteCount) {
 if (content == null) throw new NullPointerException("content == null");
 Util.checkOffsetAndCount(content.length, offset, byteCount);
 return new RequestBody() {
  @Override public @Nullable MediaType contentType() {
   return contentType;
  }
  @Override public long contentLength() {
   return byteCount;
  }
  @Override public void writeTo(BufferedSink sink) throws IOException {
   sink.write(content, offset, byteCount);
  }
 };
}

代码示例来源:origin: huxq17/SwipeCardsView

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (byteCount > bytesRemaining) {
  throw new ProtocolException("expected " + bytesRemaining
    + " bytes but received " + byteCount);
 }
 sink.write(source, byteCount);
 bytesRemaining -= byteCount;
}

代码示例来源:origin: huxq17/tractor

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (byteCount > bytesRemaining) {
  throw new ProtocolException("expected " + bytesRemaining
    + " bytes but received " + byteCount);
 }
 sink.write(source, byteCount);
 bytesRemaining -= byteCount;
}

代码示例来源:origin: duzechao/OKHttpUtils

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (byteCount > bytesRemaining) {
  throw new ProtocolException("expected " + bytesRemaining
    + " bytes but received " + byteCount);
 }
 sink.write(source, byteCount);
 bytesRemaining -= byteCount;
}

代码示例来源:origin: com.github.ljun20160606/okhttp

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (byteCount > bytesRemaining) {
  throw new ProtocolException("expected " + bytesRemaining
    + " bytes but received " + byteCount);
 }
 sink.write(source, byteCount);
 bytesRemaining -= byteCount;
}

代码示例来源:origin: apache/servicemix-bundles

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (byteCount > bytesRemaining) {
  throw new ProtocolException("expected " + bytesRemaining
    + " bytes but received " + byteCount);
 }
 sink.write(source, byteCount);
 bytesRemaining -= byteCount;
}

代码示例来源:origin: duzechao/OKHttpUtils

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (limit != -1 && content.size() > limit - byteCount) {
  throw new ProtocolException("exceeded content-length limit of " + limit + " bytes");
 }
 content.write(source, byteCount);
}

代码示例来源:origin: huxq17/SwipeCardsView

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (limit != -1 && content.size() > limit - byteCount) {
  throw new ProtocolException("exceeded content-length limit of " + limit + " bytes");
 }
 content.write(source, byteCount);
}

代码示例来源:origin: huxq17/tractor

@Override public void write(Buffer source, long byteCount) throws IOException {
 if (closed) throw new IllegalStateException("closed");
 checkOffsetAndCount(source.size(), 0, byteCount);
 if (limit != -1 && content.size() > limit - byteCount) {
  throw new ProtocolException("exceeded content-length limit of " + limit + " bytes");
 }
 content.write(source, byteCount);
}

相关文章