from the JDK 1.2.2 documentation
public final class InetAddress extends Object implements Serializable
This class represents an Internet Protocol (IP)
address. Applications should use the methods
getLocalHost, getByName,
or getAllByName
to create a new InetAddress instance.
Methods
equals(Object obj) | Compares this object against the specified object. |
byte[] getAddress( ) | Returns the raw IP address of this InetAddress object. |
static InetAddress[] getAllByName
(String host) |
Determines all the IP addresses of a host, given the host's name |
static InetAddress getByName
(String host) |
Determines the IP address of a host, given the host's name |
String getHostAddress( ) | Returns the IP address string "%d.%d.%d.%d". |
String getHostName( ) | Returns the hostname for this address. |
static InetAddress getLocalHost( ) | Returns the local host. |
int hashCode( ) | Returns a hashcode for this IP address. |
boolean isMulticastAddress( ) | Utility routine to check if the InetAddress is a IP multicast address. |
String toString( ) | Converts this IP address to a String. |
Constructors
Socket
(InetAddress address, int port) |
Creates a stream socket and connects it to the specified port number at the specified IP address. |
Socket
(String host, int port) |
Creates a stream socket and connects it to the specified port number on the named host. |
Methods
void close( ) | Closes this socket. |
InetAddress getInetAddress( ) | Returns the address to which the socket is connected. |
InputStream getInputStream( ) | Returns an input stream for this socket. |
InetAddress getLocalAddress( ) | Gets the local address to which the socket is bound. |
int getLocalPort( ) | Returns the local port to which this socket is bound. |
OutputStream getOutputStream( ) | Returns an output stream for this socket. |
int getPort( ) | Returns the remote port to which this socket is connected. |
int getReceiveBufferSize( ) | Get value of the SO_RCVBUF option for this socket, that is the buffer size used by the platform for input on the this Socket. |
int getSendBufferSize( ) | Get value of the SO_SNDBUF option for this socket, that is the buffer size used by the platform for output on the this Socket. |
int getSoLinger( ) | Returns setting for SO_LINGER. |
int getSoTimeout( ) | Returns setting for SO_TIMEOUT. |
boolean getTcpNoDelay( ) | Tests if TCP_NODELAY is enabled. |
void setReceiveBufferSize(int size) | Sets the SO_SNDBUF option to the specified value for this DatagramSocket |
void setSendBufferSize(int size) | Sets the SO_SNDBUF option to the specified value for this DatagramSocket |
static void setSocketImplFactory
(SocketImplFactory fac) |
Sets the client socket implementation factory for the application. |
void setSoLinger
(boolean on, int linger) |
Enable/disable SO_LINGER with the specified linger time in seconds. |
void setSoTimeout(int timeout) | Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. |
void setTcpNoDelay(boolean on) | Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm). |
String toString( ) | Converts this socket to a String. |
ServerSocket class is a server socket implementation. A server socket waits for requests to come in over the network. It performs some operation based on that request, and then possibly returns a result to the requester. |
Methods
Socket accept( ) | Listens for a connection to be made to this socket and accepts it. |
void close( ) | Closes this socket. |
InetAddress getInetAddress( ) | Returns the local address of this server socket. |
int getLocalPort( ) | Returns the port on which this socket is listening. |
int getSoTimeout( ) | Retrieve setting for SO_TIMEOUT. |
protected void implAccept
(Socket s) |
Subclasses of ServerSocket use this method to override accept() to return their own subclass of socket. |
static void setSocketFactory
(SocketImplFactory fac) |
Sets the server socket implementation factory for the application. |
void setSoTimeout(int timeout) | Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. |
String toString( ) | Returns the implementation, address and port of this socket as a String. |
Methods
abstract void connect( ) | Opens a communications link to the resource referenced by this URL, if such a connection has not already been established. |
boolean getAllowUserInteraction( ) | Returns the value of the allowUserInteraction field for this object. |
Object getContent( ) | Retrieves the contents of this URL connection. |
String getContentEncoding( ) | Returns the value of the content-encoding header field. |
int getContentLength( ) | Returns the value of the content-length header field. |
String getContentType( ) | Returns the value of the content-type header field. |
long getDate( ) | Returns the value of the date header field. |
static boolean
getDefaultAllowUserInteraction( ) |
Returns the default value of the allowUserInteraction field. |
static String
getDefaultRequestProperty(String key) |
Returns the value of the default request property. |
boolean getDefaultUseCaches( ) | Returns the default value of a URLConnection's useCaches flag. |
boolean getDoInput( ) | Returns the value of this URLConnection's doInput flag. |
boolean getDoOutput( ) | Returns the value of this URLConnection's doOutput flag. |
long getExpiration( ) | Returns the value of the expires header field. |
static FileNameMap getFileNameMap( ) | Returns the FileNameMap. |
String getHeaderField(int n) | Returns the value for the nth header field. |
String getHeaderField(String name) | Returns the name of the specified header field. |
long getHeaderFieldDate
(String name, long Default) |
Returns the value of the named field parsed as date. |
int getHeaderFieldInt
(String name, int Default) |
Returns the value of the named field parsed as a number. |
String getHeaderFieldKey(int n) | Returns the key for the nth header field. |
long getIfModifiedSince( ) | Returns the value of this object's ifModifiedSince field. |
InputStream getInputStream( ) | Returns an input stream that reads from this open connection. |
long getLastModified( ) | Returns the value of the last-modified header field. |
OutputStream getOutputStream( ) | Returns an output stream that writes to this connection. |
Permission getPermission( ) | Returns a permission object representing the permission necessary to make the connection represented by this object. |
String
getRequestProperty(String key) |
Returns the value of the named general request property for this connection. |
URL getURL( ) | Returns the value of this URLConnection's URL field. |
boolean getUseCaches( ) | Returns the value of this URLConnection's useCaches field. |
protected static String
guessContentTypeFromName(String fname) |
Tries to determine the content type of an object, based on the specified "file"component of a URL. |
static String
guessContentTypeFromStream (InputStream is) |
Tries to determine the type of an input stream based on the characters at the beginning of the input stream. |
void setAllowUserInteraction
(boolean allowuserinteraction) |
Set the value of the allowUserInteraction field of this URLConnection. |
static void
setContentHandlerFactory (ContentHandlerFactory fac) |
Sets the ContentHandlerFactory of an application. |
static void setDefaultAllowUserInteraction
(boolean defaultallowuserinteraction) |
Sets the default value of the allowUserInteraction field for all future URLConnection objects to the specified value. |
static void setDefaultRequestProperty
(String key, String value) |
Sets the default value of a general request property. |
void setDefaultUseCaches
(boolean defaultusecaches) |
Sets the default value of the useCaches field to the specified value. |
void setDoInput(boolean doinput) | Sets the value of the doInput field for this URLConnection to the specified value. |
void setDoOutput(boolean dooutput) | Sets the value of the doOutput field for this URLConnection to the specified value. |
static void setFileNameMap
(FileNameMap map) |
Sets the FileNameMap. |
void setIfModifiedSince
(long ifmodifiedsince) |
Sets the value of the ifModifiedSince field of this URLConnection to the specified value.` |
void setRequestProperty
(String key, String value) |
Sets the general request property. |
void setUseCaches(boolean usecaches) | Sets the value of the useCaches field of this URLConnection to the specified value. |
String toString( ) | Returns a String representation of this URL connection. |
Methods
protected void addURL(URL url) | Appends the specified URL to the list of URLs to search for classes and resources. |
protected Package definePackage
(String name, Manifest man, URL url) |
Defines a new package by name in this ClassLoader. |
protected Class
findClass(String name) |
Finds and loads the class with the specified name from the URL search path. |
URL findResource(String name) | Finds the resource with the specified name on the URL search path. |
Enumeration
findResources(String name) |
Returns an Enumeration of URLs representing all resources on the URL search path with specified name. |
protected PermissionCollection
getPermissions (CodeSource codesource) |
Returns the permissions for the given code source object. |
URL[] getURLs( ) | Returns the search path of URLs for loading classes and resources. |
static URLClassLoader
newInstance(URL[] urls) |
Creates a new instance of URLClassLoader for the specified URLs and default parent class loader. |
static URLClassLoader
newInstance (URL[] urls, ClassLoader parent) |
Creates a new instance of URLClassLoader for the specified URLs and parent class loader. |
public class URLDecoder extends
Object
URLDecoder class contains a utility
method for converting from a MIME format called "x-www-form-urlencoded"
to a String. To convert to a String, each character is examined in turn:
1) The ASCII characters ' a ' through
' z ', ' A ' through ' Z ', and ' 0 ' through ' 9 ' remain the same.
|
Method
public static String decode(String s) throws Exception //see box above |
public class URLEncoder extends
Object
public static String encode(String s) // the reverse function of the decoder class |
public final class URL extends Object implements
Serializable
Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web. A resource can be something as simple as a file or a directory, or it can be a reference to a more complicated object, such as a query to a database or to a search engine. |
Constructors
URL(String spec) | Creates a URL object from the String representation. |
URL (String protocol,
String host, int port, String file) |
Creates a URL object from the specified protocol, host, port number, and file. |
Methods
boolean equals(Object obj) | Compares two URLs. |
Object getContent( ) | Returns the contents of this URL. |
String getFile( ) | Returns the file name of this URL. |
String getHost( ) | Returns the host name of this URL, if applicable. |
int getPort( ) | Returns the port number of this URL. |
String getProtocol( ) | Returns the protocol name this URL. |
String getRef( ) | Returns the anchor (also known as the "reference") of this URL. |
int hashCode( ) | Creates an integer suitable for hash table indexing. |
URLConnection
openConnection( ) |
Returns a URLConnection object that represents a connection to the remote object referred to by the URL. |
InputStream
openStream( ) |
Opens a connection to this URL and returns an InputStream for reading from that connection. |
boolean sameFile(URL other) | Compares two URLs, excluding the "ref" fields. |
protected void set
(String protocol, String host, int port, String file, String ref) |
Sets the fields of the URL. |
static void
setURLStreamHandlerFactory (URLStreamHandlerFactory fac) |
Sets an application's URLStreamHandlerFactory.
|
String toExternalForm( ) | Constructs a string representation of this URL. |
String toString( ) | Constructs a string representation of this URL. |
public abstract class URLStreamHandler
extends Object
The abstract class URLStreamHandler
is the common superclass for all stream protocol handlers. A stream protocol
handler knows how to make a connection for a particular protocol type,
such as http, ftp, or gopher.
In most cases, an instance of a URLStreamHandler subclass is not created directly by an application. Rather, the first time a protocol name is encountered when constructing a URL, the appropriate stream protocol handler is automatically loaded. |
protected abstract URLConnection
openConnection(URL u) |
Opens a connection to the object referenced by the URL
argument.
|
protected void parseURL
(URL u, String spec, int start, int limit) |
Parses the string representation of a URL into a URL
object.
|
protected void setURL
(URL u, String protocol, String host, int port, String file, String ref) |
Sets the fields of the URL argument to the indicated values. |
protected String toExternalForm(URL u) | Converts a URL of a specific protocol to a String. |
public final class SocketPermission
extends Permission implements Serializable
This class represents access to a network via sockets. A SocketPermission consists of a host specification and a set of "actions" specifying ways to connect to that host. The possible ways to connect to the host are; 1) accept 2) connect 3) listen 4) resolve The "listen" action is only meaningful
when used with "localhost". The "resolve" (resolve host/ip name
p1 = new SocketPermission("puffin.eng.sun.com:7777", "connect,accept"); it allows that code to connect to port 7777 on puffin.eng.sun.com, and to accept connections on that port. Similarly, if the following permission: p1 = new SocketPermission("puffin.eng.sun.com:7777",
"connect,accept");
is granted to some code, it allows
that code to accept connections on, connect to, or listen on any port
Granting code permission to accept
or make connections to remote hosts may be dangerous because
|
Methods
boolean equals(Object obj) | Checks two SocketPermission objects for equality. |
String getActions( ) | Returns the canonical string representation of the actions. |
int hashCode( ) | Returns the hash code value for this object. |
boolean implies(Permission p) | Checks if this socket permission object "implies" the specified permission. |
PermissionCollection
newPermissionCollection( ) |
Returns a new PermissionCollection object for storing SocketPermission objects. |
Exception classes
BindException
ConnectException
MalformedURLException
NoRouteToHostException
ProtocolException
SocketException
UnknownHostException
UnknownServiceException
Interfaces
ContentHandlerFactory
FileNameMap
SocketImplFactory
SocketOptions
URLStreamHandlerFactory