I am new in android. I have built an project.
I have a class that check if the url exist or not like this:
public class connect {
Boolean checkServer() throws IOException
{
Boolean check = false;
HttpURLConnection connection = null;
try {
URL url = new URL("www.google.com");
connection = (HttpURLConnection) url.openConnection();
connection.connect();
connection.getInputStream();
// do something with the input stream here
check = true;
} catch (MalformedURLException e1) {
e1.printStackTrace();
check = false;
}
finally {
if(null != connection) { connection.disconnect(); }
}
return check;
}
}
And I want to run it as single file in eclipse.
How can I do this?
thank anyway
You can write a Junit class or in a simple way, write a new class with public static void main() method or with in the same class and in main() method you should create an object of the class and launch the main() method