URL u =null;
long timestamp = 0;
getImage(getDocumentBase(), "test.gif"); try {
u = new URL(getDocumentBase(), "test.gif");
URLConnection uc = u.openConnection();
uc.setUseCaches(false);
/*
** use timestamp has a reference, re-open an URLConnection
** to the same file to check if the timestamp is different
** with the getLastModified() method.
*/
timestamp = uc.getLastModified();
}
catch (Exception e) {
e.printStackTrace();}
}没隔一段时间去检查last modified time 可否?
long timestamp = 0;
getImage(getDocumentBase(), "test.gif"); try {
u = new URL(getDocumentBase(), "test.gif");
URLConnection uc = u.openConnection();
uc.setUseCaches(false);
/*
** use timestamp has a reference, re-open an URLConnection
** to the same file to check if the timestamp is different
** with the getLastModified() method.
*/
timestamp = uc.getLastModified();
}
catch (Exception e) {
e.printStackTrace();}
}没隔一段时间去检查last modified time 可否?
public class FileMonitor implements Runnable {
public static final String FILE_CHANGED_PROPERTY = "FILE_CHANGED_PROPERTY";
private File fileToMonitor;
private PropertychangeSupport; public FileMonitor(File fileToMonitor)
{
this.fileToMonitor = fileToMonitor;
pcs = new PropertychangeSupport(this);
} public void addPropertyChangeListener(PropertyChangeListener pcl)
{
pcs.addPropertyChangeListener(pcl);
} public void removePropertyChangeListener(PropertyChangeListener pcl)
{
pcs.removePropertyChangeListener(pcl);
} private Thread monitor;
public void startMonitoring() {
if (monitor != null) {
monitor = new Thread(this, /* desired priority */);
monitor.start();
}
}
private long lastModified = -1;
public void run() {
lastModified = fileToMonitor.lastModified(); // check the lastModified every so often
// if there is a difference fire the event
}
}
What i really want to know is which function i can use to refresh the current page rather than check the last modified page.
cheers.