开发者

Use a variable in a URL object in Android

Can I use a variable in the following code?

String Var = "\"http://dl.dropbox.com/u/44966/xml%20ro开发者_如何转开发ma.xml\"";
URL url1 = new URL(Var);

Is it only allowed to use a literal string, as in the following line?

URL url1 = new URL("http://dl.dropbox.com/u/44966/xml%20roma.xml");

In my application it is imperative that I use a variable.


As long as the constructor of the URL class accepts a String object, you can pass it directly or through the usage of a variable.

But your string variable, to be equivalent with the example string you present, should be like this:

String Var = "http://dl.dropbox.com/u/44966/xml%20roma.xml";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜