public abstract class ContentHandler extends Object
ContentHandler是读取所有类的超Object从URLConnection 。
应用程序通常不直接在此类中调用getContent方法。 相反,应用程序调用getContent类方法URL或URLConnection 。 应用程序的内容处理程序工厂(实现接口的类的实例ContentHandlerFactory通过调用设置为setContentHandler )是带一个String给套接字上接收的MIME类型的对象。 工厂返回一个ContentHandler子类的ContentHandler ,并调用其getContent方法来创建对象。
如果没有找到内容处理程序,URLConnection将在用户可定义的一组位置中查找内容处理程序。 默认情况下,它会在sun.net.www.content中显示,但用户可以通过定义java.content.handler.pkgs属性来定义一个垂直条分隔的类前缀集,以进行搜索。 班级的名称必须是:
{package-prefix}.{major}.{minor}
e.g.
YoyoDyne.experimental.text.plain
如果内容处理程序类的加载将由调用者的委派链之外的类加载器执行,则JVM将需要RuntimePermission“getClassLoader”。
| Constructor and Description |
|---|
ContentHandler() |
| Modifier and Type | Method and Description |
|---|---|
abstract Object |
getContent(URLConnection urlc)
给定位于对象表示开头的URL连接流,该方法读取该流并从中创建一个对象。
|
Object |
getContent(URLConnection urlc, 类[] classes)
给定位于对象表示开始处的URL连接流,该方法读取该流并创建一个与指定类型匹配的对象。
|
public abstract Object getContent(URLConnection urlc) throws IOException
urlc - 一个URL连接。
ContentHandler读取。
IOException - 如果读取对象时发生I / O错误。
public Object getContent(URLConnection urlc, 类[] classes) throws IOException
urlc - 一个URL连接。
classes - 请求的类型数组
ContentHandler读取的对象是建议类型的第一个匹配项。
如果不支持请求,则为null。
IOException - 如果读取对象时发生I / O错误。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.