Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:59:38+00:00 2026-06-13T19:59:38+00:00

Is there any possibility to upload a file (for example: an image), to a

  • 0

Is there any possibility to upload a file (for example: an image), to a site and to calculate the transfer rate?

I have some code that downloads an image from a specified url and calculates the transfer rate, using the java.net.Url class, something like:

long startTime = System.currentTimeMillis(); //start time

    System.out.println("Connecting  site...\n");
    System.out.println("Downloading......");

    URL url = new URL("http://....");
    url.openConnection();
    InputStream reader = url.openStream();

    FileOutputStream writer = new FileOutputStream("D:/imagine.jpg");
    byte[] buffer = new byte[153600];
    int totalBytesRead = 0;
    int bytesRead = 0; 

    while ((bytesRead = reader.read(buffer)) > 0)
    {  
       writer.write(buffer, 0, bytesRead);
       buffer = new byte[153600];
       totalBytesRead += bytesRead;
    }

    long endTime = System.currentTimeMillis();//end of download

    long elapsedTime=(endTime-startTime)/1000;//from miliseconds in seconds 

    System.out.println("ElapsedTime is " +elapsedTime +" s");

    int memory=new Integer(totalBytesRead);

    double memoryFinal=memory * 0.0009765625; //file in Kb

    System.out.println("File size: " +memoryFinal +"Kb");

    System.out.println("Speed :" + memoryFinal/elapsedTime + "Kbps");
    writer.close();
    reader.close();

I need something easy and useful. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:59:39+00:00Added an answer on June 13, 2026 at 7:59 pm

    Yes you can – but it is not simple.

    POSTing a file to a server is not implemented in plain java URLConnection, but you have to implements the protocol.

    Or, You can use org.apache.commons.httpclient

    http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any possibility to use old Ada code in Android? I have an
Is there any possibility to change the text-color of some parts in a textarea
Is there any possibility of giving variable name to hex/rgb numbers in .qss file
Is there any possibility in the prefix-function of a given pattern to have something
Is there any possibility of creating a view like the following image? I do
Is there any possibility to get all HTML content elements that contains plain text
Is there any possibility to set behavior on TFS that will build a project
Is there any possibility that I can directly send signal to a Java virtual
Is there any Possibility that it can Generate Compressed HTML from the GridVIew ???
Is there any possibility to manually define an image for flattered things? Or are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.