|
At 10:58 08/04/1999 , David Gibbs wrote: >Does anyone know of a open source Java class that will retrieve a web URL >and return the results as a String? I don't know if this is deprecated these days, but you might look at the URL class in java.net. I think toExternalForm() will give you what you want. The actual URL is retrieved with getDocumentBase(). Here's an example that does something not too dissimilar: /** * getPage retrieves the requested html document * @parm file The file name of the document being retrieved */ private void getPage(String file, String frame) { AppletContext context; URL urlBase; URL url; String protocol; int port; String currentFile; String path; int endOfPath; String host; context = getAppletContext(); urlBase = getDocumentBase(); protocol = urlBase.getProtocol(); port = urlBase.getPort(); host = urlBase.getHost(); currentFile = urlBase.getFile(); if ((endOfPath = currentFile.lastIndexOf("/")) == -1) { endOfPath = currentFile.lastIndexOf("\\"); } switch (endOfPath) { case -1: path = ""; break; case 0: path = ""; break; default: path = currentFile.substring(1, endOfPath); } try { url = new URL(protocol, host, port, "/" + path + "/" + file); super.showStatus(url.toExternalForm()); super.getAppletContext().showDocument(url, frame); } catch (MalformedURLException e) {} } Pete Hall pbhall@execpc.com http://www.execpc.com/~pbhall +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.