|
-
September 17th, 2000, 12:53 PM
#1
Get the File Size ....
Hi !
A Simple Question ......
From a Site (Say- www.XYZ.com) how can i get the Size of a File (Say- index.htm) ?
I want to know the Size of index.htm at the site www.xyz.com !!
Thanks ...
-Vipul Pathak.
Pathak Developers Pvt. Ltd.
Indore, (MP) INDIA.
PS: If this helps you then Rate it, so let me know How much is this helpful to you.
(*Vipul)() ; 
-
September 17th, 2000, 09:15 PM
#2
Re: Get the File Size ....
import java.io.*;
import java.net.*;
public class FileSizeFromURL {
public static final void main(String[] args) {
URL url;
URLConnection conn;
int size;
if(args.length != 1) {
System.out.println("Usage: FileSizeFromURL ");
return;
}
try {
url = new URL(args[0]);
conn = url.openConnection();
size = conn.getContentLength();
if(size < 0)
System.out.println("Could not determine file size.");
else
System.out.println(args[0] + "\nSize: " + size);
conn.getInputStream().close();
}
catch(Exception e) {
e.printStackTrace();
}
}
}
-------------------------------------------
weaver
icq# 64665116
Please rate this post.
http://weaver.x7.htmlplanet.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|