Learn how to a build a cloud-first strategyRegister Now


How to calculate the data transfered over a HTTP Connection

Posted on 2007-08-05
Medium Priority
Last Modified: 2013-11-22

I am working on a mobile application that will transfer data to a server but in order to calculate the cost for the transfer ie. Network data charge, I need to know the complete amount of data transfered including header, body content and response etc.

How can this be done?

Using: Java in NetBeans 5.5.1 with Apache 5.5.17

Thanks for your help
Question by:Dudach
LVL 16

Accepted Solution

ellandrd earned 400 total points
ID: 19634959
LVL 86

Expert Comment

ID: 19635010
Probably the best thing to do is to use a loggable proxy
LVL 51

Expert Comment

ID: 19637497
do you mean the request or the response data?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 19778813
I am looking to calculate the number of bytes being received at the server.

What I have on the server side is:
ServletInputStream in = request.getInputStream();
DataInputStream din = new DataInputStream(in);

But I want to get the number of bytes in the DataInputStream din. How can this be done?

Thanks in advance

LVL 86

Assisted Solution

CEHJ earned 400 total points
ID: 19778835
>>But I want to get the number of bytes in the DataInputStream din. How can this be done?

By reading it and counting them as it's read
LVL 51

Assisted Solution

ahoffmann earned 400 total points
ID: 19780787
number_of_bytes += din.length;

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question