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

  • Home
  • SEARCH
  • 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 7074053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:00:16+00:00 2026-05-28T06:00:16+00:00

I want to make the following HTTP request from my Java Standalone Application and

  • 0

I want to make the following HTTP request from my Java Standalone Application and save the output JSON file in my system.

Click Me

How DO i Do this

  • 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-05-28T06:00:17+00:00Added an answer on May 28, 2026 at 6:00 am

    Have you tried using java.net.URL to open a connection? (See the JavaDoc). I’ve left out the import statements, but you get the idea :).

    URL url = new URL("http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC%7CSeattle&destinations=San%20Francisco%7CVictoria%20BC&mode=bicycling&language=fr-FR&sensor=false");
    ReadableByteChannel inputChannel;
    WritableByteChannel outputChannel;
    try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        InputStream urlStream = connection.getInputStream();
    
        File outputFile = new File("/path/to/output/file");
        inputChannel = Channels.newChannel(urlStream);
        outputChannel = (new FileOutputStream(outputFile)).getChannel();
    
        outputChannel.transferFrom(inputChannel, 0, connection.getContentLength());
    } catch (IOException ioe) {
      // handle your exception here
    } finally {
        //check for nulls and stuff before you do this
        inputChannel.close();
        outputChannel.close();
    }
    

    Although if you’re going to be using RESTful web services a fair bit, you might want to investigate Jersey.

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

Sidebar

Related Questions

I want to make the following curl call in my C# console application: curl
I want to receive the following HTTP request in PHP: Content-type: multipart/form-data;boundary=main_boundary --main_boundary Content-type:
I want to make an http request (I use ksoap2) in the onCreate() during
i want to make an stylized unordered list like the following, but i don't
I want to make the grouped UITableView transparent. I partially succeded with the following
I have the following markup, and I want to make the All radio button
I have the following code for my .htaccess file that I've picked up from
So, I'm trying to make cross-site AJAX request from my own script to the
I want to upload a plist file to my server from my iphone app.
I want to create a simple URL shortner that would do the following: http://example.com/code

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.