Projet gus05 de développement Java
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
-20%
Le deal à ne pas rater :
(Adhérents Fnac) Enceinte Bluetooth Marshall Stanmore II Noir
199.99 € 249.99 €
Voir le deal

Lancer le client Web sur une URL

Aller en bas

Lancer le client Web sur une URL Empty Lancer le client Web sur une URL

Message  Gus Mer 9 Sep - 14:17

Voici une entité qui permet de lancer le client Web "Safari" de Mac pour afficher une URL

gus.env.mac.command.webbrowser

Code:
package gus05.entity.gus.env.mac.command.webbrowser;

import java.io.PrintStream;
import java.net.URL;
import gus05.framework.core.Entity;
import gus05.framework.core.Outside;
import gus05.framework.features.Give;


public class CommandWebBrowser implements Entity, Give {

    public String getName()      {return "gus.env.mac.command.webbrowser";}
    public String getCreationDate()   {return "2008.12.17";}

    private PrintStream out;

    public CommandWebBrowser() throws Exception
    {
       out = (PrintStream) Outside.resource(this,"out");
    }

    public void give(Object obj) throws Exception
    {
       URL url = toURL(obj);
       String command = "open -a /Applications/Safari.app "+url.toString();
       Runtime.getRuntime().exec(command);
       out.println("displaying url: "+url.toString()+" for mac");
    }

    private URL toURL(Object obj) throws Exception
    {
       if(obj==null || obj.equals(""))
          throw new Exception("Undefined URL");
       if(obj instanceof URL) return (URL)obj;
       return new URL(obj.toString());
    }
}
Gus
Gus
Admin

Messages : 249
Date d'inscription : 01/09/2009

http://www.gus05.com

Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum