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

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

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

URLConnection.setIfModifiedSince介绍

[英]Sets the point of time since when the data must be modified to be transmitted. Some protocols transmit data only if it has been modified more recently than a particular time. The data will be transmitted regardless of its timestamp if this option is set to 0.
[中]设置必须修改数据才能传输的时间点。有些协议仅在数据最近被修改的时间超过特定时间时才传输数据。如果此选项设置为0,则无论时间戳如何,数据都将被传输。

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. con = ProxyConfiguration.open(archive);
  2. if (lastModified != 0) {
  3. con.setIfModifiedSince(lastModified);

代码示例来源:origin: org.apache.ant/ant

  1. connection.setIfModifiedSince(timestamp);

代码示例来源:origin: apache/ignite

  1. conn.setIfModifiedSince(lastModified);

代码示例来源:origin: rakam-io/rakam

  1. connection.setIfModifiedSince(timestamp);

代码示例来源:origin: rakam-io/rakam

  1. connection.setIfModifiedSince(timestamp);

代码示例来源:origin: rakam-io/rakam

  1. connection.setIfModifiedSince(timestamp);

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

  1. @Override
  2. public void setIfModifiedSince(long ifmodifiedsince)
  3. {
  4. _conn.setIfModifiedSince(ifmodifiedsince);
  5. }

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

  1. public void setIfModifiedSince(long ifModifiedSince) {
  2. connection.setIfModifiedSince(ifModifiedSince);
  3. this.ifModifiedSince = ifModifiedSince;
  4. }

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

  1. public void setIfModifiedSince(long ifmodifiedsince) {
  2. delegateConnection.setIfModifiedSince(ifmodifiedsince);
  3. }

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

  1. public void setIfModifiedSince(long ifmodifiedsince) {
  2. connection.setIfModifiedSince(ifmodifiedsince);
  3. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. void applyConditionals(URLConnection urlConnection) {
  2. if(lastModified != 0L) {
  3. urlConnection.setIfModifiedSince(lastModified);
  4. }
  5. if(entityTags != null && entityTags.length() > 0) {
  6. urlConnection.addRequestProperty("If-None-Match", entityTags);
  7. }
  8. }

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

  1. void applyConditionals(URLConnection urlConnection) {
  2. if(lastModified != 0L) {
  3. urlConnection.setIfModifiedSince(lastModified);
  4. }
  5. if(entityTags != null && entityTags.length() > 0) {
  6. urlConnection.addRequestProperty("If-None-Match", entityTags);
  7. }
  8. }

代码示例来源:origin: com.github.houbie/rhino-mod

  1. void applyConditionals(URLConnection urlConnection) {
  2. if(lastModified != 0L) {
  3. urlConnection.setIfModifiedSince(lastModified);
  4. }
  5. if(entityTags != null && entityTags.length() > 0) {
  6. urlConnection.addRequestProperty("If-None-Match", entityTags);
  7. }
  8. }

代码示例来源:origin: com.github.tntim96/rhino

  1. void applyConditionals(URLConnection urlConnection) {
  2. if(lastModified != 0L) {
  3. urlConnection.setIfModifiedSince(lastModified);
  4. }
  5. if(entityTags != null && entityTags.length() > 0) {
  6. urlConnection.addRequestProperty("If-None-Match", entityTags);
  7. }
  8. }

代码示例来源:origin: io.apigee/rhino

  1. void applyConditionals(URLConnection urlConnection) {
  2. if(lastModified != 0L) {
  3. urlConnection.setIfModifiedSince(lastModified);
  4. }
  5. if(entityTags != null && entityTags.length() > 0) {
  6. urlConnection.addRequestProperty("If-None-Match", entityTags);
  7. }
  8. }

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

  1. private URLConnection getUrlIfNeeded(URL url, long now) throws IOException,
  2. RepositoryException {
  3. if (expires.containsKey(url) && now < expires.get(url))
  4. return null;
  5. URLConnection open = url.openConnection();
  6. open.setUseCaches(true);
  7. if (lastModified == 0)
  8. return open;
  9. open.setIfModifiedSince(lastModified);
  10. if (open.getLastModified() > lastModified)
  11. return open;
  12. return null;
  13. }

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

  1. File f = new File();// the file to download
  2. HttpURLConnection con = (HttpURLConnection) new URL("http://www.test.com/"+f.getName()).openConnection();
  3. // Add the IfModifiedSince HEADER
  4. con.setIfModifiedSince(f.lastModified());
  5. con.setRequestMethod("GET");
  6. con.connect();
  7. if(con.getResponseCode() == 304) {
  8. System.out.println(f+ " : already downloaded");
  9. } else {
  10. // Download the content again and store the image again
  11. }

代码示例来源:origin: com.twelvemonkeys/twelvemonkeys-core

  1. public long lastModified() {
  2. try {
  3. URLConnection connection = getURL().openConnection();
  4. connection.setAllowUserInteraction(false);
  5. connection.setUseCaches(true);
  6. connection.setIfModifiedSince(mLastModified);
  7. mLastModified = connection.getLastModified();
  8. }
  9. catch (IOException ignore) {
  10. }
  11. return mLastModified;
  12. }
  13. }

代码示例来源:origin: doxia/doxia-core

  1. /**
  2. * Loads the content of an URL containing text.
  3. *
  4. * @param url the URL of the text resource
  5. * @return the loaded String
  6. * @throws IOException if there is an IO problem
  7. */
  8. public static String loadString( URL url ) throws IOException
  9. {
  10. URLConnection connection = url.openConnection();
  11. connection.setDefaultUseCaches( false );
  12. connection.setUseCaches( false );
  13. connection.setIfModifiedSince( 0 );
  14. return loadString( connection.getInputStream() );
  15. }

代码示例来源:origin: doxia/doxia-core

  1. /**
  2. * Loads the content of an URL containing binary data.
  3. *
  4. * @param url the URL of the binary data
  5. * @return the loaded bytes
  6. * @throws IOException if there is an IO problem
  7. */
  8. public static byte[] loadBytes( URL url ) throws IOException
  9. {
  10. URLConnection connection = url.openConnection();
  11. connection.setDefaultUseCaches( false );
  12. connection.setUseCaches( false );
  13. connection.setIfModifiedSince( 0 );
  14. return loadBytes( connection.getInputStream() );
  15. }

相关文章

URLConnection类方法