does any one here know how i could implement a java program to
automaticaly load random or listed web pages. I thought it would be
cool to have my laptop displaying a load of pages automatically.
I do it with a java macro that compose web pages statically.
here is the code.
package com.mindprod.htmlmacros;
import java.io.File;
import java.util.Random;
public class RandomLink implements Macro
{
/**
* Generates a link to a randomly chose url,
* which could be as small as a single letter or even "".
* invoked with:
* <!-- macro RandomLink this.html
http://mindprod.com/that.html
.../else.html -->
*
* @param parms takes variable number of parms, reprsenting
possible choice strings to generate.
* @param fileBeingProcessed
* @return one of the choices.
*/
public String expand ( String[] parms, File fileBeingProcessed,
boolean quiet )
{
if ( ! quiet )
{
System.out.print( "R" );
}
if ( parms.length == 0 )
{
throw new IllegalArgumentException ( "RandomLink needs list
of choices." );
}
return expand( parms );
}
/**
* expand RandomLink macro guts
*
* @param choices array of possible choices to choose from
* @return on of the choice strings, randomly chosen
*/
public String expand ( String[] choices )
{
Random wheel = new Random( );
int pick = wheel.nextInt( choices.length );
return "<a href=\"" +choices[ pick ] + "\">";
}
}
If want an applet that loads a random page, see
http://mindprod.com/jgloss/applet.html#LOADING