Back to project page DroidUPnP.
The source code is released under:
GNU General Public License
If you think the Android project DroidUPnP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package fi.iki.elonen; /*from w ww. j av a2 s. c o m*/ import java.io.IOException; public class ServerRunner { public static void run(Class serverClass) { try { executeInstance((NanoHTTPD) serverClass.newInstance()); } catch (Exception e) { e.printStackTrace(); } } public static void executeInstance(NanoHTTPD server) { try { server.start(); } catch (IOException ioe) { System.err.println("Couldn't start server:\n" + ioe); System.exit(-1); } System.out.println("Server started, Hit Enter to stop.\n"); try { System.in.read(); } catch (Throwable ignored) { } server.stop(); System.out.println("Server stopped.\n"); } }