How do I retrieve a URL in Java?

Let’s learn how do I retrieve a URL in Java. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

How do I retrieve a URL from a web site using Java?

I want to use HTTP GET and POST commands to retrieve URLs from a website and parse the HTML. How do I do this?


You can use HttpURLConnection in combination with URL. URL url = new URL(""...

Read more

Johnny Maelstrom at Stack Overflow Mark as irrelevant Undo

Other solutions

Need a re-write of a Java / Python Spider

Specifically for efn-ga, however, as he may not want to do it, everyone with Java and Python skills is welcome to give it a go. I need a re-write of a Java / Python spider that I wrote myself. I've been tweaking it off and on as time permits, however...


Dear coolguy90210, Among the posts you made above after I had posted my multi-threaded Spider code...

Read more

coolguy90210-ga at Google Answers Mark as irrelevant Undo

Querying Google from Java program (URL, openStream())

I try to send a query directly to Google with java program and receive the results(not using Google API). Here is the (part of) java code that I was created for the purpose. String urlName = "://"; URL url = new...


Hi mrz I strongly suspect that there is nothing wrong with your code; rather it is Google's policy...

Read more

mrz-ga at Google Answers Mark as irrelevant Undo

URL Stream Text in java?

Hello am trying to make a news feed am having problems making a loop that displays next line in a text file. i can only make it go though first line i tryed alot of things i tryed making a array list and display like that. nothing worked. anyone can...


Try this first just to make sure you're seeing any data from your stream. This reads in characters without...

Read more

Andreas at Yahoo! Answers Mark as irrelevant Undo

How can I encode URL in java?

I have an url like the one below, http://example-server:8080/v1?url=  How can i encode the above url completely  I tried with but it didn't encode the url completely  can someone...


URLEncoder.encode() works just fine: import; import; public...

Read more

Luigi Mistrik at Quora Mark as irrelevant Undo

WordPress Plugin Development: How do I retrieve the destination url of a redirected page with wp_remote_head()?

The following function returns the url of a redirected page. function get_destination_url_curl( $url ) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false...


wp_remote_head() should return a 'location' index in the resulting array... $result = wp_remote_head...

Read more

Russell Heimlich at Quora Mark as irrelevant Undo

Is this a browser redirect or legit URL for Java?

I installed the newest Java update today 6 Update 21. I went directly to to do so. But I noticed in my internet connections the following url along with (I'm putting some spaces here so nobody accidentally clicks on it) sunmicro-2....


The real Java site is I don't get directed to the site you mention. Does not...

Read more

Yahoo! Answers Mark as irrelevant Undo

Is there an open source URL manipulation library in Java?

The requirements: Conversion to/from String, like Extraction and manipulation of parameters, both query and hash (for JavaScript apps) Access to the parts of the URL: scheme, host, path


Adam is correct in that there is no single library that does everything you want. The class...

Read more

Ryan J. McDonough at Quora Mark as irrelevant Undo

How can I simulate the behavior of curl -k <url> in Java?

I'm trying to poll a HTTPS URL on a local server, but cannot due to security certificate issues. If I try to 'curl' it on CLI, still it would complain. See here: Software Engineering: What is the cause of this exception, which happens when I try to open...


You can use SSLSocketFactory in connection with HTTPSURLConnection as described here How do I accept...

Read more

Asher Syed at Quora Mark as irrelevant Undo

Why does java script deny URL/links?

On some websites on specific links/buttons (ex: The button to print on yahoo mail and the search button on addicting games) do not work. I checked java script (it was on) and there were a lot of errors with URLs This is what it said: Unsafe JavaScript...


That's weird

Read more

Jennifer at Yahoo! Answers Mark as irrelevant Undo

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.