com.faa.dom.tutorial
Class URLSaver

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.faa.dom.tutorial.URLSaver

public class URLSaver
extends java.lang.Thread

This class saves the contents of a given URL to a local disk


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
URLSaver(java.lang.String newBaseURL, java.lang.String newBaseDir)
          A Constructor that sets the base URL and Base directories.
 
Method Summary
 void run()
           
 void saveURL(java.lang.String url)
          save url using the name of the file on the url and the default directory
 void saveURLAs(java.lang.String url, java.lang.String filename)
          Save the given URL to a file, using a particular filename.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLSaver

public URLSaver(java.lang.String newBaseURL,
                java.lang.String newBaseDir)
         throws java.net.MalformedURLException
A Constructor that sets the base URL and Base directories.
Parameters:
baseURL - a base URL String for subsequent calls to saveURLAs. Note that this doesn't mean the URLSaver cannot be used to save URLs outside the base. It is just a matter of convenience.
baseDir - a base Directory name for subsequent calls to saveURLAs
Method Detail

saveURLAs

public void saveURLAs(java.lang.String url,
                      java.lang.String filename)
               throws java.net.MalformedURLException,
                      java.io.IOException
Save the given URL to a file, using a particular filename. Both the filename and the URL can be relative, in which case, the previously set bases will be taken into consideration.
Parameters:
url - the source URL
filename - the target filename
Throws:
java.net.MalformedURLException - if the URL is not valid
java.io.IOException - if the file is not writable

saveURL

public void saveURL(java.lang.String url)
             throws java.net.MalformedURLException,
                    java.io.IOException
save url using the name of the file on the url and the default directory
Parameters:
String - url the target url
Throws:
java.net.MalformedURLException - if the URL is not valid
java.io.IOException - if the file is not writable

run

public void run()
Overrides:
run in class java.lang.Thread