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.
String urlString = "http://m.nasdaq.com/symbol/"+stock_symbol.getText();
In your Java program, you can use a String containing this text to create a URL object: URL myURL = new URL("http://example.com/"); The URL object created above represents an absolute URL. An absolute URL contains all of the information necessary to reach the resource in question.
You should first convert your string into a URI , then convert the URI into a URL . For example: String str = "http://google.com"; URI uri = new URI(str); URL url = uri. toURL();
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);
you most create a new Url and input your string in C URL url=new URL(urlString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With