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

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

本文整理了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

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

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

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

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

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

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

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

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

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

相关文章

URLConnection类方法