This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Help Needed Urgently: File Upload help Required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help Needed Urgently: File Upload help Required" Watch "Help Needed Urgently: File Upload help Required" New topic
Author

Help Needed Urgently: File Upload help Required

Declan Conlon
Ranch Hand

Joined: Jul 03, 2001
Posts: 34
Anyone know how to determine the ammount of data that has been tranferred to a server once the applet has written its byte[] to a DataOutputStream. I thought DataOutputStream.size() would work but it only returns the size of the byte[] not the ammout of data transferred to the server. The calculation/determination must be done client side.
Could anyone help me out of a hole here? Thanks for all of your help.
Bipul Bhattacharjee
Greenhorn

Joined: Jul 19, 2001
Posts: 4
Hi Declan,
Think u want to know the size of the file.Make an instanse of your data stream in to a file and u can easily get the size of the file.
fis = new FileInputStream(source);
File file=new File(source);
long filesz=file.length();
Bipul

Declan Conlon
Ranch Hand

Joined: Jul 03, 2001
Posts: 34
No I need to get the actual length of the data being transferred to the servlet, not a static filesize.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
If the total data isn't too big you can build your DataOutputStream from a ByteArrayOutputStream. When everything has been written you can look at the resulting byte[] size before actually sending it.
Bill

------------------
author of:
 
 
subject: Help Needed Urgently: File Upload help Required