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

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

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

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

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

connection.setIfModifiedSince(timestamp);

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

conn.setIfModifiedSince(lastModified);

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

connection.setIfModifiedSince(timestamp);

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

connection.setIfModifiedSince(timestamp);

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

connection.setIfModifiedSince(timestamp);

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

@Override
public void setIfModifiedSince(long ifmodifiedsince)
{
  _conn.setIfModifiedSince(ifmodifiedsince);
}

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

public void setIfModifiedSince(long ifModifiedSince) {
  connection.setIfModifiedSince(ifModifiedSince);
  this.ifModifiedSince = ifModifiedSince;
}

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

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

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

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

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

void applyConditionals(URLConnection urlConnection) {
  if(lastModified != 0L) {
    urlConnection.setIfModifiedSince(lastModified);
  }
  if(entityTags != null && entityTags.length() > 0) {
    urlConnection.addRequestProperty("If-None-Match", entityTags);
  }
}

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

void applyConditionals(URLConnection urlConnection) {
  if(lastModified != 0L) {
    urlConnection.setIfModifiedSince(lastModified);
  }
  if(entityTags != null && entityTags.length() > 0) {
    urlConnection.addRequestProperty("If-None-Match", entityTags);
  }
}

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

void applyConditionals(URLConnection urlConnection) {
  if(lastModified != 0L) {
    urlConnection.setIfModifiedSince(lastModified);
  }
  if(entityTags != null && entityTags.length() > 0) {
    urlConnection.addRequestProperty("If-None-Match", entityTags);
  }
}

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

void applyConditionals(URLConnection urlConnection) {
  if(lastModified != 0L) {
    urlConnection.setIfModifiedSince(lastModified);
  }
  if(entityTags != null && entityTags.length() > 0) {
    urlConnection.addRequestProperty("If-None-Match", entityTags);
  }
}

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

void applyConditionals(URLConnection urlConnection) {
  if(lastModified != 0L) {
    urlConnection.setIfModifiedSince(lastModified);
  }
  if(entityTags != null && entityTags.length() > 0) {
    urlConnection.addRequestProperty("If-None-Match", entityTags);
  }
}

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

private URLConnection getUrlIfNeeded(URL url, long now) throws IOException,
    RepositoryException {
  if (expires.containsKey(url) && now < expires.get(url))
    return null;
  URLConnection open = url.openConnection();
  open.setUseCaches(true);
  if (lastModified == 0)
    return open;
  open.setIfModifiedSince(lastModified);
  if (open.getLastModified() > lastModified)
    return open;
  return null;
}

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

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

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

public long lastModified() {
    try {
      URLConnection connection = getURL().openConnection();
      connection.setAllowUserInteraction(false);
      connection.setUseCaches(true);
      connection.setIfModifiedSince(mLastModified);

      mLastModified = connection.getLastModified();
     }
    catch (IOException ignore) {
    }

    return mLastModified;
  }
}

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

/**
 * Loads the content of an URL containing text.
 *
 * @param url the URL of the text resource
 * @return the loaded String
 * @throws IOException if there is an IO problem
 */
public static String loadString( URL url ) throws IOException
{
  URLConnection connection = url.openConnection();
  connection.setDefaultUseCaches( false );
  connection.setUseCaches( false );
  connection.setIfModifiedSince( 0 );
  return loadString( connection.getInputStream() );
}

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

/**
 * Loads the content of an URL containing binary data.
 *
 * @param url the URL of the binary data
 * @return the loaded bytes
 * @throws IOException if there is an IO problem
 */
public static byte[] loadBytes( URL url ) throws IOException
{
  URLConnection connection = url.openConnection();
  connection.setDefaultUseCaches( false );
  connection.setUseCaches( false );
  connection.setIfModifiedSince( 0 );
  return loadBytes( connection.getInputStream() );
}

相关文章

URLConnection类方法