本文整理了Java中java.net.URLConnection.getContentHandler()
方法的一些代码示例,展示了URLConnection.getContentHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URLConnection.getContentHandler()
方法的具体详情如下:
包路径:java.net.URLConnection
类名称:URLConnection
方法名:getContentHandler
[英]Gets the Content Handler appropriate for this connection.
[中]获取适用于此连接的内容处理程序。
代码示例来源:origin: robovm/robovm
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException
* if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: robovm/robovm
return getContentHandler(contentType).getContent(this, types);
代码示例来源:origin: jtulach/bck2brwsr
/**
* Retrieves the contents of this URL connection.
*
* @param classes the <code>Class</code> array
* indicating the requested types
* @return the object fetched that is the first match of the type
* specified in the classes array. null if none of
* the requested types are supported.
* The <code>instanceof</code> operator should be used to
* determine the specific kind of object returned.
* @exception IOException if an I/O error occurs while
* getting the content.
* @exception UnknownServiceException if the protocol does not support
* the content type.
* @see java.net.URLConnection#getContent()
* @see java.net.ContentHandlerFactory#createContentHandler(java.lang.String)
* @see java.net.URLConnection#getContent(java.lang.Class[])
* @see java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory)
* @since 1.3
*/
public Object getContent(Class[] classes) throws IOException {
// Must call getInputStream before GetHeaderField gets called
// so that FileNotFoundException has a chance to be thrown up
// from here without being caught.
getInputStream();
return getContentHandler().getContent(this, classes);
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Retrieves the contents of this URL connection.
*
* @param classes the <code>Class</code> array
* indicating the requested types
* @return the object fetched that is the first match of the type
* specified in the classes array. null if none of
* the requested types are supported.
* The <code>instanceof</code> operator should be used to
* determine the specific kind of object returned.
* @exception IOException if an I/O error occurs while
* getting the content.
* @exception UnknownServiceException if the protocol does not support
* the content type.
* @see java.net.URLConnection#getContent()
* @see java.net.ContentHandlerFactory#createContentHandler(java.lang.String)
* @see java.net.URLConnection#getContent(java.lang.Class[])
* @see java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory)
* @since 1.3
*/
public Object getContent(Class[] classes) throws IOException {
// Must call getInputStream before GetHeaderField gets called
// so that FileNotFoundException has a chance to be thrown up
// from here without being caught.
getInputStream();
return getContentHandler().getContent(this, classes);
}
代码示例来源:origin: jtulach/bck2brwsr
return getContentHandler().getContent(this);
代码示例来源:origin: org.apidesign.bck2brwsr/emul
return getContentHandler().getContent(this);
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException
* if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: com.jtransc/jtransc-rt
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException
* if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: MobiVM/robovm
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException
* if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: ibinti/bugvm
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException
* if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: com.jtransc/jtransc-rt
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type. The content type must match with one of
* the list {@code types}.
*
* @param types the list of acceptable content types.
* @return the content representing object or {@code null} if the content
* type does not match with one of the specified types.
* @throws IOException if an error occurs obtaining the content.
*/
// Param is not generic in spec
@SuppressWarnings("unchecked")
public Object getContent(Class[] types) throws IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this, types);
}
return null;
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException
* if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: com.gluonhq/robovm-rt
return getContentHandler(contentType).getContent(this, types);
代码示例来源:origin: FlexoVM/flexovm
/**
* Returns an object representing the content of the resource this {@code
* URLConnection} is connected to. First, it attempts to get the content
* type from the method {@code getContentType()} which looks at the response
* header field "Content-Type". If none is found it will guess the content
* type from the filename extension. If that fails the stream itself will be
* used to guess the content type.
*
* @return the content representing object.
* @throws IOException
* if an error occurs obtaining the content.
*/
public Object getContent() throws java.io.IOException {
if (!connected) {
connect();
}
if ((contentType = getContentType()) == null) {
if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
contentType = guessContentTypeFromStream(getInputStream());
}
}
if (contentType != null) {
return getContentHandler(contentType).getContent(this);
}
return null;
}
代码示例来源:origin: MobiVM/robovm
return getContentHandler(contentType).getContent(this, types);
代码示例来源:origin: ibinti/bugvm
return getContentHandler(contentType).getContent(this, types);
代码示例来源:origin: FlexoVM/flexovm
return getContentHandler(contentType).getContent(this, types);
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
return getContentHandler(contentType).getContent(this, types);
代码示例来源:origin: com.bugvm/bugvm-rt
return getContentHandler(contentType).getContent(this, types);
内容来源于网络,如有侵权,请联系作者删除!