diff --git a/src/main/java/cokr/xit/foundation/web/BrowserLauncher.java b/src/main/java/cokr/xit/foundation/web/BrowserLauncher.java new file mode 100644 index 0000000..1dab38d --- /dev/null +++ b/src/main/java/cokr/xit/foundation/web/BrowserLauncher.java @@ -0,0 +1,30 @@ +package cokr.xit.foundation.web; + +import java.awt.Desktop; +import java.net.URI; + +/**웹 브라우저 구동기 + * @author mjkhan + */ +public class BrowserLauncher { + /**주어진 url의 웹 자원을 시스템 디폴트 웹 브라우저로 연다. + * @param url URL + */ + public static final void launch(String url) { + if (Desktop.isDesktopSupported()) { + try { + Desktop.getDesktop().browse(new URI(url)); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Runtime.getRuntime().exec( + String.format("rundll32 url.dll, FileProtocolHandler %s", url) + ); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} \ No newline at end of file