I'm having a problem creating a URL using a string variable. For example this approach returns a "Cannot be null" error due to the line URL theURL = new URL(OutboundURL):
Using java Syntax Highlighting
- try{
- String OutboundURL;
- String Username = "someusername";
- OutboundURL = "http://www.somewebsite.com/someservice.php?un=" + Username;
- URL theURL = new URL(OutboundURL);
- InputStream in = theURL.openStream();
- int b = in.read();
- while(b != -1){
- b = in.read();
- }
- }
- catch(MalformedURLException e){
- }
- catch(IOException e){
- }
Parsed in 0.013 seconds, using GeSHi 1.0.8.4
However the approach above works perfectly if I don't use a string variable:
Using java Syntax Highlighting
- URL theURL = new URL("http://www.somewebsite.com/someservice.php?un=someusername");
Parsed in 0.010 seconds, using GeSHi 1.0.8.4
My question is what's the difference between these two:
"http://www.somewebsite.com/someservice.php?un=someusername"
versus
OutboundURL = "http://www.somewebsite.com/someservice.php?un=" + Username
Thanks in advance.