From an applet, how do I get information, like size and creation time, about a file on the server?

0
Posted

From an applet, how do I get information, like size and creation time, about a file on the server?

0

Location: http://www.jguru.com/faq/view.jsp?EID=75649 Created: Jun 14, 2000 Modified: 2001-08-18 17:30:02.807 Author: Brian O’Byrne (http://www.jguru.com/guru/viewbio.jsp?EID=38567) Question originally posed by Steven Li (http://www.jguru.com/guru/viewbio.jsp?EID=62131 Assuming you have access to the file in question through a web server, you can use the URLConnection methods getContentLength() and getLastModified(). URL fileOfInterest = new URL(…); URLConnection connectionToFileOfInterest = fileOfInterest.getConnection(); int contentLength = connectionToFileOfInterest.getContentLength(); long lastModifiedTime = connectionToFileOfInterest.getLastModified(); You cannot get the creation time this way. Warning: this is not reliable across Web servers and you may end up downloading the file completely to get the size.

Related Questions