import java.applet.*; import java.net.*; import java.io.*; import java.util.*; import java.awt.*; import java.text.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.html.*; import javax.swing.text.*; import javax.swing.text.html.parser.*; import javax.swing.text.MutableAttributeSet; import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.HTMLEditorKit.Parser; import javax.swing.text.html.HTMLEditorKit.ParserCallback; public class AgetPageArr05 extends JApplet { static String GsStg = "/live/"; static String TTxt, TTxt2; static String IOFile = "http://nfl.com/scores/2002/week15"; static String[] outArr, outArr2; static Reader reader; static URL baseAddress; static String LivePage_PropFile; public String[] getPageStgArr() { /* html: java: private String urlOfDataFile; urlOfDataFile = getParameter("UrlOfDataFile"); fileURL = new URL(urlOfDataFile); */ LivePage_PropFile = getParameter("LivePagePropFile"); //String LP_propsfile = "LivePage.properties"; Properties LP_props = new Properties (); //System.out.println("LP_propsfile: " + LP_propsfile); try { LP_props.load(new BufferedInputStream(new FileInputStream(LivePage_PropFile))); outArr2 = new String[LP_props.size()]; System.out.println("LP_props.size(): " + LP_props.size()); for (int n = 0; n < LP_props.size(); n++) { outArr2[n] = LP_props.getProperty("LivePage." + n); } return outArr2; } catch ( IOException e) {} TTxt = "";TTxt2 = ""; HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback () { public void handleStartTag(HTML.Tag tag, MutableAttributeSet attributes, int pos) { if (tag == HTML.Tag.A) { Enumeration e = attributes.getAttributeNames(); while (e.hasMoreElements()) { Object name = e.nextElement(); String value = (String) attributes.getAttribute(name); if (name == HTML.Attribute.HREF) { TTxt = TTxt + value + "\n"; } } } } }; try { if (IOFile.indexOf("://")>-1) { baseAddress = new URL(IOFile); URLConnection uc = baseAddress.openConnection(); InputStream content = (InputStream)uc.getInputStream(); reader = new BufferedReader (new InputStreamReader (content)); } else { reader = new FileReader(IOFile); } // Trick to use Swing's HTML parser Parser parser = (new HTMLEditorKit() { public Parser getParser() { return super.getParser(); } }).getParser(); parser.parse(reader, callback, true); stgToArray sta = new stgToArray(); outArr = sta.stringToArray(TTxt); for (int j = 0; j < outArr.length; j++) { if ( outArr[j].indexOf(GsStg) >= 0) { TTxt2 = TTxt2 + outArr[j] + "\n"; } } stgToArray sta2 = new stgToArray(); outArr2 = sta2.stringToArray(TTxt2); } catch (MalformedURLException e) { System.out.println("Bad url: "+e+"\n"); } catch (IOException ie) { System.out.println("Bad io: "+ie+"\n"); } return outArr2; } }