java.net.URLConnection.getHeaderFieldLong()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(277)

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

URLConnection.getHeaderFieldLong介绍

[英]Returns the value of the named field parsed as a number.

This form of getHeaderField exists because some connection types (e.g., http-ng) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing.
[中]返回解析为数字的命名字段的值。
这种形式的getHeaderField之所以存在,是因为某些连接类型(例如http-ng)具有预解析的头。该连接类型的类可以重写此方法并缩短解析过程。

代码示例

代码示例来源:origin: org.apidesign.bck2brwsr/emul

  1. /**
  2. * Returns the value of the <code>content-length</code> header field as a
  3. * long.
  4. *
  5. * @return the content length of the resource that this connection's URL
  6. * references, or <code>-1</code> if the content length is
  7. * not known.
  8. * @since 7.0
  9. */
  10. public long getContentLengthLong() {
  11. return getHeaderFieldLong("content-length", -1);
  12. }

代码示例来源:origin: jtulach/bck2brwsr

  1. /**
  2. * Returns the value of the <code>content-length</code> header field as a
  3. * long.
  4. *
  5. * @return the content length of the resource that this connection's URL
  6. * references, or <code>-1</code> if the content length is
  7. * not known.
  8. * @since 7.0
  9. */
  10. public long getContentLengthLong() {
  11. return getHeaderFieldLong("content-length", -1);
  12. }

代码示例来源:origin: freeplane/freeplane

  1. public long getHeaderFieldLong(String name, long Default) {
  2. return connection.getHeaderFieldLong(name, Default);
  3. }

代码示例来源:origin: com.jtransc/jtransc-rt

  1. public long getContentLengthLong() {
  2. return getHeaderFieldLong("Content-Length", -1);
  3. }

代码示例来源:origin: octo-online/reactive-audit

  1. @Test(expected = NetworkReactiveAuditException.class)
  2. public void getHeaderFieldLong()
  3. throws IOException
  4. {
  5. Assume.assumeTrue(IOTestTools.isNetworkConnected());
  6. ReactiveAudit.off.commit();
  7. URLConnection conn = new URL("http://" + HOST + ":" + PORT).openConnection();
  8. TestTools.strict.commit();
  9. conn.getHeaderFieldLong("expiration", 0);
  10. }

相关文章

URLConnection类方法