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

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

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

URLConnection.getExpiration介绍

[英]Returns the timestamp when this response will be expired in milliseconds since January 1, 1970 GMT or 0 if this timestamp is unknown.
[中]返回自1970年1月1日GMT或0(如果此时间戳未知)起,此响应将以毫秒为单位过期的时间戳。

代码示例

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

TileBitmap result = this.graphicFactory.createTileBitmap(inputStream, this.downloadJob.tile.tileSize,
      this.downloadJob.hasAlpha);
  result.setExpiration(urlConnection.getExpiration());
  return result;
} catch (CorruptedInputStreamException e) {

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

@Override
public long getExpiration()
{
 return super.getExpiration();
}

代码示例来源:origin: org.eclipse.jetty.osgi/jetty-osgi-boot-warurl

@Override
public long getExpiration()
{
  return _conn.getExpiration();
}

代码示例来源:origin: org.dihedron.commons/dihedron-commons

/**
 * Returns the expiration date of the response data.
 * 
 * @return
 *   the expiration date of the response data.
 */
public long getExpiration() {
  return connection.getExpiration();
}

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

public long getExpiration() {
  return connection.getExpiration();
}

代码示例来源:origin: org.jboss/jboss-common-core

public long getExpiration() {
 return delegateConnection.getExpiration();
}

代码示例来源:origin: org.microemu/microemu-javase

public long getExpiration() throws IOException {
  if (cn == null) {
    throw new IOException();
  }
  if (!connected) {
    cn.connect();
    connected = true;
  }
  return cn.getExpiration();
}

代码示例来源:origin: stackoverflow.com

URL url=new URL("http://msyserver/abc/servlet1");
URLConnection con=url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.getExpiration();//<----------
OutputStream os=con.getOutputStream();
ObjectOutputStream oos=new ObjectOutputStream(os);
oos.writeObject(pushEmailDTO);
oos.flush();
oos.close();

代码示例来源:origin: org.samba.jcifs/jcifs

public long getExpiration() {
  try {
    handshake();
  } catch (IOException ex) { }
  return connection.getExpiration();
}

代码示例来源:origin: io.robe/robe-assets

/**
 * Loads http from the http
 *
 * @return
 */
private byte[] loadAssetFromURL() {
  try {
    URLConnection cnn = this.asset.openConnection();
    cnn.connect();
    int b = -1;
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    while ((b = cnn.getInputStream().read()) != -1)
      stream.write(b);
    stream.flush();
    stream.close();
    this.lastModified = cnn.getLastModified();
    this.expireAt = cnn.getExpiration();
    this.ETAG = cnn.getHeaderField(HttpHeaders.ETAG);
    return stream.toByteArray();
  } catch (IOException e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: lexs/webimageloader

private long getExpires(URLConnection urlConnection) {
  if (forcedMaxAge > 0) {
    return System.currentTimeMillis() + forcedMaxAge;
  } else if (forcedMaxAge == Constants.MAX_AGE_INFINITY) {
    return Metadata.NEVER_EXPIRES;
  }
  // Prefer "max-age" before "expires"
  long maxAge = HeaderParser.getMaxAge(urlConnection);
  if (maxAge > 0) {
    return System.currentTimeMillis() + maxAge * 1000;
  }
  long expires = urlConnection.getExpiration();
  if (expires > 0) {
    return expires;
  }
  // Use default
  return System.currentTimeMillis() + defaultMaxAge;
}

代码示例来源:origin: robeio/robe

/**
 * Loads http from the http
 *
 * @return
 */
private byte[] loadAssetFromURL() {
  try {
    URLConnection cnn = this.asset.openConnection();
    cnn.connect();
    int b = -1;
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    while ((b = cnn.getInputStream().read()) != -1)
      stream.write(b);
    stream.flush();
    stream.close();
    this.lastModified = cnn.getLastModified();
    this.expireAt = cnn.getExpiration();
    this.ETAG = cnn.getHeaderField(HttpHeaders.ETAG);
    return stream.toByteArray();
  } catch (IOException e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-repository

private synchronized long loadIndex(URL url, URLConnection conn,
    Map<URL, URI> map) throws IOException {
  long modified = conn.getLastModified();
  long expiration = conn.getExpiration();
  RDFFormat format = findRdfFormat(url, conn, null);
  if (format == null) {
    Properties p = new Properties();
    p.load(conn.getInputStream());
    map.clear();
    for (Map.Entry e : p.entrySet()) {
      String path = e.getKey().toString();
      String context = e.getValue().toString();
      Enumeration<URL> resources = cl.getResources(path);
      while (resources.hasMoreElements()) {
        URL dataset = resources.nextElement();
        map.put(dataset, createURI(context, dataset));
      }
    }
  } else if (!map.containsKey(url)) {
    map.put(url, createURI(null, url));
  }
  if (expiration > 0) {
    expires.put(url, expiration);
  }
  return modified;
}

代码示例来源:origin: stackoverflow.com

System.out.println("Content-Type: " +
hpCon.getContentType());
System.out.println("Expires: " + hpCon.getExpiration());
System.out.println("Last-Modified: " +
new Date(hpCon.getLastModified()));

代码示例来源:origin: org.apache.synapse/synapse-core

wre.setLastModified(connection.getLastModified());
wre.setVersion(connection.getLastModified());
if (connection.getExpiration() > 0) {
  wre.setCachableDuration(
      connection.getExpiration() - System.currentTimeMillis());
} else {
  wre.setCachableDuration(getCachableDuration());

代码示例来源:origin: wso2/wso2-synapse

wre.setLastModified(connection.getLastModified());
wre.setVersion(connection.getLastModified());
if (connection.getExpiration() > 0) {
  wre.setCachableDuration(
      connection.getExpiration() - System.currentTimeMillis());
} else {
  wre.setCachableDuration(getCachableDuration());

代码示例来源:origin: org.openrdf.elmo/elmo-repository

private synchronized long reload(URL dataset, URLConnection url, URI context)
    throws RepositoryException, IOException, RDFParseException {
  RDFFormat format = findRdfFormat(dataset, url, RDFFormat.RDFXML);
  logger.info("Loading {}", dataset);
  long modified = url.getLastModified();
  long expiration = url.getExpiration();
  RepositoryConnection conn = super.getConnection();
  try {
    conn.setAutoCommit(false);
    conn.clear(context);
    conn.add(url.getInputStream(), dataset.toExternalForm(), format,
        context);
    conn.commit();
  } finally {
    conn.close();
  }
  if (expiration > 0) {
    expires.put(dataset, expiration);
  }
  return modified;
}

代码示例来源:origin: org.mapsforge/mapsforge-map

TileBitmap result = this.graphicFactory.createTileBitmap(inputStream, this.downloadJob.tile.tileSize,
      this.downloadJob.hasAlpha);
  result.setExpiration(urlConnection.getExpiration());
  return result;
} catch (CorruptedInputStreamException e) {

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

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

相关文章

URLConnection类方法