|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.util.Convert
com.ccg.util.TagLookup
com.ccg.util.CommandLineUtility
com.ccg.net.URLCat
public class URLCat
Command line utility to fetch document data, status or info from a
URL.
This utility is useful for determining information about a
particular URL. In particular it is capable of
displaying the following information:
URL specified, and some information about the
client and server involved.URL specified.URL specified.The command line arguments recognized are of the form:
java com.ccg.net.URLCat -url URL [-info] [-header] [-body] \
[-out FILE] [-useCache [true|false]] [-hex] [-flush [true|false]]
encoded in the proper form for
passing to the server. For example, to pass: "name=Paul
Blankenbaker" and "age=37", use:
-k.0 name -v.0 "Paul Blankenbaker" -k.1 age -v.1 37
Some of the arguments recognized by the CommandLineUtility class can also
be used (such as: "-args FILE").
Here are two sample usages, the first one retrieves the document "http://my.yahoo.com" and stores it in a file, the second gets just the header information, the third gets just the general information, and the fourth retreives ALL three in one shot:
java com.ccg.net.URLCat -url "http://my.yahoo.com/" -out /tmp/my.html java com.ccg.net.URLCat -url "http://my.yahoo.com/" -header java com.ccg.net.URLCat -url "http://my.yahoo.com/" -info java com.ccg.net.URLCat -url "http://my.yahoo.com/" -info -header -body
| Constructor Summary | |
|---|---|
URLCat(String[] args)
Constructs the object with a set of command line arguments. |
|
| Method Summary | |
|---|---|
InputStream |
getURLInputStream()
Fetch a InputStream to read data in from. |
boolean |
getUseCaches()
Indicates whether we try to make use of HTTP cacheing. |
boolean |
isFlushEnabled()
Is should we flush the output as soon as data is received and written set? |
boolean |
isHexDump()
Will a hex dump of the content received be done? |
static void |
main(String[] args)
Main entry point into the application. |
void |
run()
Does the actual reading and processing of the information. |
void |
setFlushEnabled(boolean val)
Set should we flush the output as soon as data is received and written. |
void |
setHexDump(boolean val)
Set whether we should do a hex instead of a ASCII dump. |
void |
setUseCaches(boolean val)
Set should we enable the use of HTTP caches? |
| Methods inherited from class com.ccg.util.CommandLineUtility |
|---|
getFiles, getInputStream, getLineNumberReader, getOutputStream, getPrintWriter, getStrings, setInputStream, setOutputStream |
| Methods inherited from class com.ccg.util.TagLookup |
|---|
get, getBoolean, getChoice, getColor, getDate, getDate, getFont, getIndexedList, getInputStream, getLocale, getLookup, getNumber, getNumber, getOutputStream, getString, getString, getStrings, getTag, getTimeSpan, getTimeSpan, setLookup, setTag |
| Methods inherited from class com.ccg.util.Convert |
|---|
choiceValue, getDateFormat, getNumberFormat, setDateFormat, setNumberFormat, toBoolean, toColor, toDate, toFont, toInputStream, toLocale, toNumber, toOutputStream, toString, toTimeSpan |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public URLCat(String[] args)
This method constructs a new URLCat object and
initializes with a array of string values which are treated as
command line arguments. The command line arguments are processed
(as specified in the class overview and parent class).
args - Array of command line arguments.| Method Detail |
|---|
public void setFlushEnabled(boolean val)
val - New boolean value to assign.isFlushEnabled()public boolean isFlushEnabled()
setFlushEnabled(boolean)
public InputStream getURLInputStream()
throws IOException
InputStream to read data in from.
This method will open the connection to the desired URL and POST any arguments (if necessary). It will then return a
InputStream which one may read the data
returned from the server.
Note, the POST method will be used if the NAME/VALUE pairs are
specified on the command line (as indicated in the class overview). If no NAME/VALUE pairs are specified, then the
standard GET will be used to retrieve the information.
InputStream to read the data from.
IOException - If there is a problem establishing the connection.run()public void run()
This method is responsible for the actual reading and
processing of information related to the URL in question. It will
do one or more of the following (depending upon the command line
arguments specified - see the class overview for
more details about the supported command line arguments):
URL, and the
capabilities and configuration of both the client and server
involved.
URL (like
the last time it was modified).
URL and writes it to the standard
output. This can be handy to fetch a web document and store it to
disk - but you should not enable the other options in this case.
run in interface Runnablerun in class CommandLineUtilitypublic void setUseCaches(boolean val)
val - New boolean value to assign.
see #getUseCachespublic boolean getUseCaches()
public void setHexDump(boolean val)
val - New boolean value to assign.
see #getHexDumppublic boolean isHexDump()
public static void main(String[] args)
Simply constructs the object and passes control to the run() method.
args - Array of command line arguments.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||