如何知道使用Android Java上次修改网页的日期?或者我如何申请
If-Modified-Since:如果内容未更改,则允许返回304 Not Modified
使用http标头?
答案 0 :(得分:3)
我可以这样做:
URL url = null;
try {
url = new URL("http://www.example.com/example.pdf");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HttpURLConnection httpCon = null;
try {
httpCon = (HttpURLConnection) url.openConnection();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long date = httpCon.getLastModified();