This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread 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


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: 13001
    
    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:
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Help Needed Urgently: File Upload help Required
 
It's not a secret anymore!