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

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

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

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

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

  1. @Override
  2. public long getExpiration()
  3. {
  4. return super.getExpiration();
  5. }

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

  1. @Override
  2. public long getExpiration()
  3. {
  4. return _conn.getExpiration();
  5. }

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

  1. /**
  2. * Returns the expiration date of the response data.
  3. *
  4. * @return
  5. * the expiration date of the response data.
  6. */
  7. public long getExpiration() {
  8. return connection.getExpiration();
  9. }

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

  1. public long getExpiration() {
  2. return connection.getExpiration();
  3. }

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

  1. public long getExpiration() {
  2. return delegateConnection.getExpiration();
  3. }

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

  1. public long getExpiration() throws IOException {
  2. if (cn == null) {
  3. throw new IOException();
  4. }
  5. if (!connected) {
  6. cn.connect();
  7. connected = true;
  8. }
  9. return cn.getExpiration();
  10. }

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

  1. URL url=new URL("http://msyserver/abc/servlet1");
  2. URLConnection con=url.openConnection();
  3. con.setDoOutput(true);
  4. con.setDoInput(true);
  5. con.getExpiration();//<----------
  6. OutputStream os=con.getOutputStream();
  7. ObjectOutputStream oos=new ObjectOutputStream(os);
  8. oos.writeObject(pushEmailDTO);
  9. oos.flush();
  10. oos.close();

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

  1. public long getExpiration() {
  2. try {
  3. handshake();
  4. } catch (IOException ex) { }
  5. return connection.getExpiration();
  6. }

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

  1. /**
  2. * Loads http from the http
  3. *
  4. * @return
  5. */
  6. private byte[] loadAssetFromURL() {
  7. try {
  8. URLConnection cnn = this.asset.openConnection();
  9. cnn.connect();
  10. int b = -1;
  11. ByteArrayOutputStream stream = new ByteArrayOutputStream();
  12. while ((b = cnn.getInputStream().read()) != -1)
  13. stream.write(b);
  14. stream.flush();
  15. stream.close();
  16. this.lastModified = cnn.getLastModified();
  17. this.expireAt = cnn.getExpiration();
  18. this.ETAG = cnn.getHeaderField(HttpHeaders.ETAG);
  19. return stream.toByteArray();
  20. } catch (IOException e) {
  21. e.printStackTrace();
  22. throw new RuntimeException(e);
  23. }
  24. }

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

  1. private long getExpires(URLConnection urlConnection) {
  2. if (forcedMaxAge > 0) {
  3. return System.currentTimeMillis() + forcedMaxAge;
  4. } else if (forcedMaxAge == Constants.MAX_AGE_INFINITY) {
  5. return Metadata.NEVER_EXPIRES;
  6. }
  7. // Prefer "max-age" before "expires"
  8. long maxAge = HeaderParser.getMaxAge(urlConnection);
  9. if (maxAge > 0) {
  10. return System.currentTimeMillis() + maxAge * 1000;
  11. }
  12. long expires = urlConnection.getExpiration();
  13. if (expires > 0) {
  14. return expires;
  15. }
  16. // Use default
  17. return System.currentTimeMillis() + defaultMaxAge;
  18. }

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

  1. /**
  2. * Loads http from the http
  3. *
  4. * @return
  5. */
  6. private byte[] loadAssetFromURL() {
  7. try {
  8. URLConnection cnn = this.asset.openConnection();
  9. cnn.connect();
  10. int b = -1;
  11. ByteArrayOutputStream stream = new ByteArrayOutputStream();
  12. while ((b = cnn.getInputStream().read()) != -1)
  13. stream.write(b);
  14. stream.flush();
  15. stream.close();
  16. this.lastModified = cnn.getLastModified();
  17. this.expireAt = cnn.getExpiration();
  18. this.ETAG = cnn.getHeaderField(HttpHeaders.ETAG);
  19. return stream.toByteArray();
  20. } catch (IOException e) {
  21. e.printStackTrace();
  22. throw new RuntimeException(e);
  23. }
  24. }

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

  1. private synchronized long loadIndex(URL url, URLConnection conn,
  2. Map<URL, URI> map) throws IOException {
  3. long modified = conn.getLastModified();
  4. long expiration = conn.getExpiration();
  5. RDFFormat format = findRdfFormat(url, conn, null);
  6. if (format == null) {
  7. Properties p = new Properties();
  8. p.load(conn.getInputStream());
  9. map.clear();
  10. for (Map.Entry e : p.entrySet()) {
  11. String path = e.getKey().toString();
  12. String context = e.getValue().toString();
  13. Enumeration<URL> resources = cl.getResources(path);
  14. while (resources.hasMoreElements()) {
  15. URL dataset = resources.nextElement();
  16. map.put(dataset, createURI(context, dataset));
  17. }
  18. }
  19. } else if (!map.containsKey(url)) {
  20. map.put(url, createURI(null, url));
  21. }
  22. if (expiration > 0) {
  23. expires.put(url, expiration);
  24. }
  25. return modified;
  26. }

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

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

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

  1. wre.setLastModified(connection.getLastModified());
  2. wre.setVersion(connection.getLastModified());
  3. if (connection.getExpiration() > 0) {
  4. wre.setCachableDuration(
  5. connection.getExpiration() - System.currentTimeMillis());
  6. } else {
  7. wre.setCachableDuration(getCachableDuration());

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

  1. wre.setLastModified(connection.getLastModified());
  2. wre.setVersion(connection.getLastModified());
  3. if (connection.getExpiration() > 0) {
  4. wre.setCachableDuration(
  5. connection.getExpiration() - System.currentTimeMillis());
  6. } else {
  7. wre.setCachableDuration(getCachableDuration());

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

  1. private synchronized long reload(URL dataset, URLConnection url, URI context)
  2. throws RepositoryException, IOException, RDFParseException {
  3. RDFFormat format = findRdfFormat(dataset, url, RDFFormat.RDFXML);
  4. logger.info("Loading {}", dataset);
  5. long modified = url.getLastModified();
  6. long expiration = url.getExpiration();
  7. RepositoryConnection conn = super.getConnection();
  8. try {
  9. conn.setAutoCommit(false);
  10. conn.clear(context);
  11. conn.add(url.getInputStream(), dataset.toExternalForm(), format,
  12. context);
  13. conn.commit();
  14. } finally {
  15. conn.close();
  16. }
  17. if (expiration > 0) {
  18. expires.put(dataset, expiration);
  19. }
  20. return modified;
  21. }

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

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

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

  1. @Test(expected = NetworkReactiveAuditException.class)
  2. public void getExpiration()
  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.getExpiration();
  10. }

相关文章

URLConnection类方法