top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How can I measure the file downloading time using servlets?

+2 votes
56 views
How can I measure the file downloading time using servlets?
posted Dec 9, 2015 by Joy Nelson

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
           ServletOutputStream out = response.getOutputStream();
           String filename = getServletContext().getRealPath(request.getQueryString());
           FileInputStream fin = new FileInputStream(filename);
           long start = System.currentTimeMillis();
           byte data[] = new byte[1024];
           int len = 0;
           while ((len = fin.read(data)) > 0) {
              out.write(data, 0, len);
           }
           out.flush();
           long stop = System.currentTimeMills();
           log("took " + (stop - start) + "ms to download " + filename);
answer Dec 11, 2015 by Karthick.c
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...