Java
string url = "";
// TEST CASES
url = "http://newsroom.lds.org/ldsnewsroom/eng/news-releases-stories/local-churches-teach-how-to-plan-for-disasters"; //Prints "BROKEN", although this is getting re-written to good url below.
//url = "http://beta-newsroom.lds.org/article/local-churches-teach-how-to-plan-for-disasters"; // Prints "GOOD"
//url = "http://"; //Prints "BROKEN"
//url = "google.com"; //Prints "BROKEN" althought this should be good.
//url = "www.google.com"; //Prints "BROKEN" althought this should be good.
//url = "http://www.google.com"; //Prints "GOOD"
try
{
if (url != "")
{
WebRequest Irequest = WebRequest.Create(url);
WebResponse Iresponse = Irequest.GetResponse();
if (Iresponse != null)
{
_txbl.Text = "GOOD";
}
}
}
catch (Exception ex)
{
_txbl.Text = "BROKEN";
}
Gomathi PalaniswamyRank #714 · 3.3K reputationPosted Sep 29, 2010, 10:03 PM EDT
take the url string and test what are the char you need and how to it should be.
George Loveless3 reputationPosted Sep 30, 2010, 6:39 AM EDT
I'm not sure I know what you mean. I don't want to check the url with a regular expression it that's what you mean. My code test cases might make my question more clear. I don't know why my code appears jumbled on this forum... frustrating.
Sam HobbsRank #107 · 20.5K reputationPosted Sep 30, 2010, 2:36 PM EDT
at the end of each line. I am not sure if it helps to use