Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
179 views
in Technique[技术] by (71.8m points)

java - how to insert %20 in place of space in android

I have a xml URL file in which there are white spaces i want to replace white spaces with %20.. how to do this????

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();

/** Send URL to parse XML Tags */
URL sourceUrl = new URL(
                "http://www.arteonline.mobi/iphone/output.php?gallery=MALBA%20-%20MUSEO%20DE%20ARTE%20LATINOAMERICANO%20DE%20BUENOS%20AIRES");

XMLHandlerartistspace myXMLHandler = new XMLHandlerartistspace();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this:

String temp = http://www.arteonline.mobi/iphone/output.php?gallery=MALBA%20-%20MUSEO%20DE%20ARTE%20LATINOAMERICANO%20DE%20BUENOS%20AIRES

temp = temp.replaceAll(" ", "%20");
URL sourceUrl = new URL(temp);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...