6

I have a string. i.e.

String urlString = "http://m.nasdaq.com/symbol/"+stock_symbol.getText();

I need to keep it a string because I'm asking the user for the stock symbol then performing the search. I then need to parse the information that is in the html code. So I need to convert my urlString into an URL. I looked on the android developer and saw this:

URL(String spec) 
  Creates a URL object from the String representation.

but this isn't working. Need help I also need help parsing the actual html. You don't need to give me everything, just a very short example would be great.

1
  • 2
    but this isn't working Why? Please, show us a complete example that demonstrate the issue, and tell us what doesn't work, why, what is the expected behaviour and what's happening instead. If there is any error, post the full stack trace in the question. Commented Dec 6, 2016 at 20:29

2 Answers 2

14

URL is a class. Simply use new to create a new instance of the class and pass the string as a parameter to the constructor.

String urlString = "http://m.nasdaq.com/symbol/"+stock_symbol.getText();
URL myURL = new URL(urlString);
Sign up to request clarification or add additional context in comments.

Comments

1

you most create a new Url and input your string in C URL url=new URL(urlString);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.