# URL error (MalformedURLException)

**URL:** <https://discourse.processing.org/t/url-error-malformedurlexception/35585>\
**Category:** Coding Questions\
**Created:** [March 6, 2022, 2:51am UTC](https://discourse.processing.org/t/url-error-malformedurlexception/35585 "2022-03-06T02:51:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gidiav](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@gidiav](https://discourse.processing.org/u/gidiav)\
**Post date:** [March 6, 2022, 2:51am UTC](https://discourse.processing.org/t/url-error-malformedurlexception/35585/1 "2022-03-06T02:51:45Z")

</div>

Hello,  
I am new to Processing and also to Java (though I’ve coded a lot in other languages). I am trying to read some text from a web page for my sketch, so I tried to follow the instructions in [this link](https://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html), and do something like:  
` URL rurl = new URL("http://www.oracle.com/");`  
However this is not working, and I keep getting `MalformedURLException`, regardless of the url that I use (including the one in the Oracle example, or “[http://example.com](http://example.com)”).

The error apparently occurs before the code is executed, seemingly because the IDE tries to execute the command. This seems weird and also makes it difficult to debug. (Again I am a Java novice, maybe that’s how it is in Java-land.)

I hope some Java or URL experts who can shed light on this problem… Thanks in advance!

---

<div class="post-metadata">

**Author:** ![th75](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@th75](https://discourse.processing.org/u/th75)\
**Post date:** [March 7, 2022, 7:00pm UTC](https://discourse.processing.org/t/url-error-malformedurlexception/35585/2 "2022-03-07T19:00:13Z")

</div>

hi,

this example from oracle works, but when you call “[http://www.oracle.com/](http://www.oracle.com/)” it s redirected to “[https://www.oracle.com/](https://www.oracle.com/)” this redirection is not handled by this code  
if you change to https in you code it will work:

```auto
import java.net.*;
import java.io.*;
void setup() {
  try {
    URL oracle = new URL("https://www.oracle.com/");
    BufferedReader in = new BufferedReader(
      new InputStreamReader(oracle.openStream()));

    String inputLine;
    while ((inputLine = in.readLine()) != null)
      println(inputLine);
    in.close();
  }
  catch(Exception e) {
    println(e);
  }
}

```

however, you can use the “loadStrings” from processing too, code will be more simple:

```auto
void setup() {
  String[] html= loadStrings("https://www.oracle.com/");
  println(html);
}

```

---

<div class="post-metadata">

**Author:** ![gidiav](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@gidiav](https://discourse.processing.org/u/gidiav)\
**Post date:** [March 7, 2022, 10:20pm UTC](https://discourse.processing.org/t/url-error-malformedurlexception/35585/3 "2022-03-07T22:20:32Z")

</div>

Thanks!

I am still not clear why this was breaking (it worked in java outside of processing). But I’ll just use loadStrings!
