문제

How can I know the date a webpage last-modified using Android Java? or how I can request for

If-Modified-Since: Allows a 304 Not Modified to be returned if content is unchanged

using http headers?

도움이 되었습니까?

해결책

I could do it this way:

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top