Java Doc for URL.java in  » Apache-Harmony-Java-SE » java-package » java » net » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.net 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.net.URL

URL
final public class URL implements java.io.Serializable(Code)
An instance of class URL specifies the location of a resource on the world wide web as specified by RFC 1738.


Field Summary
transient  URLStreamHandlerstrmHandler
    

Constructor Summary
public  URL(String spec)
     Constructs a new URL instance by parsing the specification.
public  URL(URL context, String spec)
     Constructs a new URL by parsing the specification given by spec and using the context provided by context.
public  URL(URL context, String spec, URLStreamHandler handler)
     Constructs a new URL by parsing the specification given by spec and using the context provided by context.
public  URL(String protocol, String host, String file)
     Constructs a new URL instance using the arguments provided.
public  URL(String protocol, String host, int port, String file)
     Constructs a new URL instance using the arguments provided.
public  URL(String protocol, String host, int port, String file, URLStreamHandler handler)
     Constructs a new URL instance using the arguments provided.

Method Summary
public  booleanequals(Object o)
     Compares the argument to the receiver, and answers true if they represent the same URL.
 voidfixURL(boolean fixHost)
    
public  StringgetAuthority()
     Answers the authority component of this URL.
final public  ObjectgetContent()
     Answers an Object representing the resource referenced by this URL.
final public  ObjectgetContent(Class[] types)
     Answers an Object representing the resource referenced by this URL.
public  intgetDefaultPort()
     Returns the default port for this URL as defined by the URLStreamHandler.
public  StringgetFile()
     Answers the file component of this URL.
public  StringgetHost()
     Answers the host component of this URL.
public  StringgetPath()
     Answers the path component of this URL.
public  intgetPort()
     Answers the port component of this URL.
public  StringgetProtocol()
     Answers the protocol component of this URL.
public  StringgetQuery()
     Answers the query component of this URL.
public  StringgetRef()
     Answers the reference component of this URL.
public  StringgetUserInfo()
     Answers the user info component of this URL.
public  inthashCode()
     Answers a hash code for this URL object.
public  URLConnectionopenConnection()
     Creates a connection to this URL using the appropriate ProtocolHandler.
public  URLConnectionopenConnection(Proxy proxy)
     The method is the same as openConnection() except that it uses the proxy to establish a connection to this URL using appropriate ProtocolHandler.
final public  InputStreamopenStream()
     Answers a stream for reading from this URL.
public  booleansameFile(URL otherURL)
     Answers true if the receiver and the argument refer to the same file.
protected  voidset(String protocol, String host, int port, String file, String ref)
     Sets the properties of this URL using the provided arguments.
protected  voidset(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)
     Sets the properties of this URL using the provided arguments.
public static synchronized  voidsetURLStreamHandlerFactory(URLStreamHandlerFactory streamFactory)
     Sets the URL Stream (protocol) handler factory.
 voidsetupStreamHandler()
     Sets the receiver's stream handler to one which is appropriate for its protocol.
public  StringtoExternalForm()
     Create and return the String representation of this URL.
public  StringtoString()
     Answers a string containing a concise, human-readable description of the receiver.
public  URItoURI()
    

Field Detail
strmHandler
transient URLStreamHandler strmHandler(Code)
The URL Stream (protocol) Handler




Constructor Detail
URL
public URL(String spec) throws MalformedURLException(Code)
Constructs a new URL instance by parsing the specification.
Parameters:
  spec - java.lang.String a URL specification.
throws:
  MalformedURLException - if the spec could not be parsed as an URL.



URL
public URL(URL context, String spec) throws MalformedURLException(Code)
Constructs a new URL by parsing the specification given by spec and using the context provided by context.

The protocol of the specification is obtained by parsing the spec string.

If the spec does not specify a protocol:

  • If the context is null, then a MalformedURLException.
  • If the context is not null, then the protocol is obtained from the context.
If the spec does specify a protocol:
  • If the context is null, or specifies a different protocol than the spec, the context is ignored.
  • If the context is not null and specifies the same protocol as the specification, the properties of the new URL are obtained from the context.

Parameters:
  context - java.net.URL URL to use as context.
Parameters:
  spec - java.lang.String a URL specification.
throws:
  MalformedURLException - if the spec could not be parsed as an URL.



URL
public URL(URL context, String spec, URLStreamHandler handler) throws MalformedURLException(Code)
Constructs a new URL by parsing the specification given by spec and using the context provided by context.

If the handler argument is non-null, a security check is made to verify that user-defined protocol handlers can be specified.

The protocol of the specification is obtained by parsing the spec string.

If the spec does not specify a protocol:

  • If the context is null, then a MalformedURLException.
  • If the context is not null, then the protocol is obtained from the context.
If the spec does specify a protocol:
  • If the context is null, or specifies a different protocol than the spec, the context is ignored.
  • If the context is not null and specifies the same protocol as the specification, the properties of the new URL are obtained from the context.

Parameters:
  context - java.net.URL URL to use as context.
Parameters:
  spec - java.lang.String a URL specification.
Parameters:
  handler - java.net.URLStreamHandler a URLStreamHandler.
throws:
  MalformedURLException - if the spec could not be parsed as an URL



URL
public URL(String protocol, String host, String file) throws MalformedURLException(Code)
Constructs a new URL instance using the arguments provided.
Parameters:
  protocol - String the protocol for the URL.
Parameters:
  host - String the name of the host.
Parameters:
  file - the name of the resource.
throws:
  MalformedURLException - if the parameters do not represent a valid URL.



URL
public URL(String protocol, String host, int port, String file) throws MalformedURLException(Code)
Constructs a new URL instance using the arguments provided.
Parameters:
  protocol - String the protocol for the URL.
Parameters:
  host - String the name of the host.
Parameters:
  port - int the port number.
Parameters:
  file - String the name of the resource.
throws:
  MalformedURLException - if the parameters do not represent a valid URL.



URL
public URL(String protocol, String host, int port, String file, URLStreamHandler handler) throws MalformedURLException(Code)
Constructs a new URL instance using the arguments provided. If the handler argument is non-null, a security check is made to verify that user-defined protocol handlers can be specified.
Parameters:
  protocol - the protocol for the URL.
Parameters:
  host - the name of the host.
Parameters:
  port - the port number.
Parameters:
  file - the name of the resource.
Parameters:
  handler - the stream handler that this URL uses.
throws:
  MalformedURLException - if the parameters do not represent an URL.




Method Detail
equals
public boolean equals(Object o)(Code)
Compares the argument to the receiver, and answers true if they represent the same URL. Two URLs are equal if they have the same file, host, port, protocol, and reference components.
Parameters:
  o - the object to compare with this URL. true if the object is the same as this URL,false otherwise.
See Also:   URL.hashCode()



fixURL
void fixURL(boolean fixHost)(Code)



getAuthority
public String getAuthority()(Code)
Answers the authority component of this URL. the receiver's authority.



getContent
final public Object getContent() throws IOException(Code)
Answers an Object representing the resource referenced by this URL. The object of the resource pointed by this URL.
throws:
  IOException - If an error occurred obtaining the content.



getContent
final public Object getContent(Class[] types) throws IOException(Code)
Answers an Object representing the resource referenced by this URL.
Parameters:
  types - The list of acceptable content types The object of the resource pointed by this URL, or null if thecontent does not match a specified content type.
throws:
  IOException - If an error occurred obtaining the content.



getDefaultPort
public int getDefaultPort()(Code)
Returns the default port for this URL as defined by the URLStreamHandler. the default port for this URL
See Also:   URLStreamHandler.getDefaultPort



getFile
public String getFile()(Code)
Answers the file component of this URL. the receiver's file.



getHost
public String getHost()(Code)
Answers the host component of this URL. the receiver's host.



getPath
public String getPath()(Code)
Answers the path component of this URL. the receiver's path.



getPort
public int getPort()(Code)
Answers the port component of this URL. the receiver's port.



getProtocol
public String getProtocol()(Code)
Answers the protocol component of this URL. the receiver's protocol.



getQuery
public String getQuery()(Code)
Answers the query component of this URL. the receiver's query.



getRef
public String getRef()(Code)
Answers the reference component of this URL. the receiver's reference component.



getUserInfo
public String getUserInfo()(Code)
Answers the user info component of this URL. the receiver's user info.



hashCode
public int hashCode()(Code)
Answers a hash code for this URL object. the hashcode for hashtable indexing



openConnection
public URLConnection openConnection() throws IOException(Code)
Creates a connection to this URL using the appropriate ProtocolHandler. The connection to this URL.
throws:
  IOException - if the connection to the URL is not possible.



openConnection
public URLConnection openConnection(Proxy proxy) throws IOException(Code)
The method is the same as openConnection() except that it uses the proxy to establish a connection to this URL using appropriate ProtocolHandler. The connection to this URL.
Parameters:
  proxy - the proxy which is used to make the connection
exception:
  IOException - thrown if an IO error occurs during connectionestablishment
exception:
  SecurityException - thrown if a security manager is installed and it deniesthe permission to connect to the proxy.
exception:
  IllegalArgumentException - thrown if the proxy is null or of an invalid type.
exception:
  UnsupportedOperationException - thrown if the protocol handler doesn't support thismethod.



openStream
final public InputStream openStream() throws java.io.IOException(Code)
Answers a stream for reading from this URL. a stream on the contents of the resource.
throws:
  IOException - if a stream could not be created.



sameFile
public boolean sameFile(URL otherURL)(Code)
Answers true if the receiver and the argument refer to the same file. All components except the reference are compared.
Parameters:
  otherURL - URL to compare against. true if the same resource, false otherwise



set
protected void set(String protocol, String host, int port, String file, String ref)(Code)
Sets the properties of this URL using the provided arguments. This method is used both within this class and by the URLStreamHandler code.
Parameters:
  protocol - the new protocol.
Parameters:
  host - the new host name.
Parameters:
  port - the new port number.
Parameters:
  file - the new file component.
Parameters:
  ref - the new reference.
See Also:   URL
See Also:   URLStreamHandler



set
protected void set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)(Code)
Sets the properties of this URL using the provided arguments. This method is used both within this class and by the URLStreamHandler code.
Parameters:
  protocol - the new protocol.
Parameters:
  host - the new host name.
Parameters:
  port - the new port number.
Parameters:
  authority - the new authority.
Parameters:
  userInfo - the new user info.
Parameters:
  path - the new path component.
Parameters:
  query - the new query.
Parameters:
  ref - the new reference.
See Also:   URL
See Also:   URLStreamHandler



setURLStreamHandlerFactory
public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory streamFactory)(Code)
Sets the URL Stream (protocol) handler factory. This method can be invoked only once during an application's lifetime.

A security check is performed to verify that the current Policy allows the stream handler factory to be set.
Parameters:
  streamFactory - URLStreamHandlerFactory The factory to use for finding streamhandlers.




setupStreamHandler
void setupStreamHandler()(Code)
Sets the receiver's stream handler to one which is appropriate for its protocol. Throws a MalformedURLException if no reasonable handler is available.

Note that this will overwrite any existing stream handler with the new one. Senders must check if the strmHandler is null before calling the method if they do not want this behavior (a speed optimization).




toExternalForm
public String toExternalForm()(Code)
Create and return the String representation of this URL. the external representation of this URL.
See Also:   URL.toString()
See Also:   URL
See Also:   URLStreamHandler.toExternalForm(URL)



toString
public String toString()(Code)
Answers a string containing a concise, human-readable description of the receiver. a printable representation for the receiver.



toURI
public URI toURI() throws URISyntaxException(Code)
Creates a URI related with this URL a URI related to this URL
throws:
  URISyntaxException - if this URL cannot format into URI



Methods inherited from java.lang.Object
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final public Class<? extends Object> getClass()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
final public void notify()(Code)(Java Doc)
final public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final public void wait(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait(long millis) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.