getLastModified()方法返回的是Header里的内容,如果没有这一项就返回零,也就是70年1月1日。
public long getLastModified() 
Returns the value of the last-modified header field. The result is the number of milliseconds since January 1, 1970 GMT
所以不妨看看是不是服务器的问题?

解决方案 »

  1.   

    http://ent.163.com/edit/030217/030217_151910.html 这个就是1970
    http://www.samsungmonitor.com.cn/Products/151S.html 这个就是正确的我也没看出什么来啊不过有时候这两个函数(获得时间和大小的)会抛出下面这个异常java.net.MalformedURLException: no protocol:
      

  2.   

    url.openConnection()是个什么东西?
    getLastModified()是HttpServlet的方法
    getContentLength()是request的方法
      

  3.   

    我就是想用java获得一个URL的网页最后的修改时间和网页的大小啊帮忙啊!
      

  4.   

    你可以试着做以下工作
    打开网页后 在 地址栏里输入 javascript:document.lastModified
    可以看到这个网页的最后修改时间不过 getLastModified() 这个函数一般是用在 Servlet 中的
      

  5.   

    可是,我现在是一个c/s的程序啊,是一个application啊,怎么才能得到呢?
      

  6.   

    -9.765625E-4 ('cause the length is unknown, so equals to -1/1024)getContentLength
    public int getContentLength()
    Returns the value of the content-length header field. Returns:
    the content length of the resource that this connection's URL references, or -1 if the content length is not known.
      

  7.   

    哦,楼上的意思是说现在我获得的是 hreader field中的信息,所以不准那我不用这个函数,还有其他函数吗?我现在就是要实现这个功能啊!!!(得到URL的长度和最后更新时间)
      

  8.   

    这个是可欲不可求的,主要取决于服务器的设置。我粗粗的看了一下,
    http://ent.163.com/edit/030217/030217_151910.html unix机器apache
    http://www.samsungmonitor.com.cn/Products/151S.html windows机器iis我个人觉得有点难。我过会儿再看看吧。
      

  9.   

    use getDate() to get the time.
      

  10.   

    不成啊,网页修改时间怎么用getdate啊?
      

  11.   

    http://expert.csdn.net/Expert/topic/1561/1561648.xml?temp=.430401
    关注!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!