Author Archive

  • Java 6 Como Correr Un Applet Con Javascript

    0

    Java 6 update 10 trae un par de cosas nuevas de las cuales hoy vamos a ver como deployar un applet en un html usando una nueva tecnica con JavaScript.

    <script src="http://java.com/js/deployJava.js"></script>
    
    <script>
      deployJava.runApplet({codebase:"http://www.example.com/applets/",
         archive:"ExampleApplet.jar", code:"Main.class",
         width:"320", Height:"400"}, null, "1.6");
    </script>
    
  • Como Ver La Version De Ubuntu Instalada

    0

    Si tienen instalado el server y no saben que version esta instalado este comando los va a ayudar.

    cat /etc/issue
    

    O este otro mas detallado

    cat /etc/lsb-release
    
  • Como Usar Nimbus Look And Feel Como Default

    0

    Con una linea en la inicializacion de tu programa Java vas a poder ver todo como Look And Feel Nimbus.

    swing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
    
  • Como Mover Carpetas Con Java

    0

    Muy sencillamente podemos mover folders usando un script como este.

    // the file we want to move
    File file = new File("original.txt");
    
    // the directory of destination
    File folder = new File("newFolder");
    
    File newPath = new File(folder, file.getName());
    
    // Move file to new directory
    boolean success = file.renameTo(newPath);
    System.out.println("file moved ok: "   success);
    
  • Como Publicar RSS Con Java Rome

    0

    Really Simple Sindication (RSS) es un excelente standard para distribuir noticias en tu website. Hoy en dia cualquiera tiene RSS desde Clarin.com hasta YO :D.



    Buscando encontre una API oficial de SUN para generar RSS 0.90, RSS 0.91 Netscape, RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3 y Atom 1.0.



    En este articulo vamos a ver como generar un output RSS utilizando ROME.

    Para empezar hay que bajarse la API ROME desde aca y ademas hay que bajar JDOM el cual es una API de DOM exclusiva para Java desde aca.

    Una vez que tenemos el jar rome-1.0RC1.jar y jdom.jar en nuestro CLASSPATH podemos empezar a codificar una sencilla clase RSSWriter.

    import com.sun.syndication.feed.synd.SyndContentImpl;
    import com.sun.syndication.feed.synd.SyndEntryImpl;
    import com.sun.syndication.feed.synd.SyndFeed;
    import com.sun.syndication.feed.synd.SyndFeedImpl;
    import com.sun.syndication.io.SyndFeedOutput;
    
    public class RSSWriter {
    
    SyndFeed feed = new SyndFeedImpl();
    
    public RSSWriter() {
    	this.feed.setFeedType("rss_2.0"); // si es que queremos este formato
    }
    
    public void setTitle(String title) {
    	this.feed.setTitle(title);
    }
    
    public void setType(String type) {
    	this.feed.setFeedType(type);
    }
    
    public void setLink(String link) {
    	this.feed.setLink(link);
    }
    
    public void setDescription(String description) {
    	this.feed.setDescription(description);
    }
    
    public void addEntry(String title, String link, Date date, String text) {
    	SyndEntryImpl entry = new SyndEntryImpl();
    	entry.setTitle(title);
    	entry.setLink(link);
    	entry.setPublishedDate(date);
    	SyndContentImpl description = new SyndContentImpl();
    	description.setType("text/plain");
    	description.setValue(text);
    	entry.setDescription(description);
    	List entries = this.feed.getEntries();
    	if (entries == null) {
    		entries = new ArrayList();
    		this.feed.setEntries(entries);
    	}
    	entries.add(entry);
    }
    
    public void serialize(Writer writer) throws Exception {
    	SyndFeedOutput output = new SyndFeedOutput();
    	output.output(this.feed, writer);
    }
    
    public void serialize(File file) throws Exception {
    	SyndFeedOutput output = new SyndFeedOutput();
    	output.output(this.feed, file);
    }
    
    public String serialize() throws Exception {
    	SyndFeedOutput output = new SyndFeedOutput();
    	return output.outputString(this.feed);
    }
    
    }
    

    Y mas que facil el utilizarla.

    RSSWriter writer = new RSSWriter();
    writer.setTitle("Algun titulito");
    writer.setDescription("Mis ultimas noticias");
    writer.setLink("http://www.rodrigoasensio.com");
    writer.addEntry("Nuevo post!", "http://rodrigoasensio.com/permalink/xx",
    new Date(), "Este es el texto de contenido que puede ser HTML");
    writer.serialize(new FileOutputStream("/usr/share/tomcat/webapps/ROOT/feed.xml"));
    

    El delivery de noticias con este estandard tan sencillo revoluciono la manera de obtener informacion con los readers y demas. Lo que mostre aca es solo una pequenia parte de toda la API. Rome ademas tiene subprojects entre los cuales figuran ROME Fetcher que provee cache feed-fetcher, ROME Propono que provee Atom protocol y MetaWeblog API.

Page 30 of 49« First...1020«2829303132»40...Last »