java.net.URLConnection.getContentHandler()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中java.net.URLConnection.getContentHandler()方法的一些代码示例,展示了URLConnection.getContentHandler()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URLConnection.getContentHandler()方法的具体详情如下:
包路径:java.net.URLConnection
类名称:URLConnection
方法名:getContentHandler

URLConnection.getContentHandler介绍

[英]Gets the Content Handler appropriate for this connection.
[中]获取适用于此连接的内容处理程序。

代码示例

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException
  11. * if an error occurs obtaining the content.
  12. */
  13. public Object getContent() throws java.io.IOException {
  14. if (!connected) {
  15. connect();
  16. }
  17. if ((contentType = getContentType()) == null) {
  18. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  19. contentType = guessContentTypeFromStream(getInputStream());
  20. }
  21. }
  22. if (contentType != null) {
  23. return getContentHandler(contentType).getContent(this);
  24. }
  25. return null;
  26. }

代码示例来源:origin: robovm/robovm

  1. return getContentHandler(contentType).getContent(this, types);

代码示例来源:origin: jtulach/bck2brwsr

  1. /**
  2. * Retrieves the contents of this URL connection.
  3. *
  4. * @param classes the <code>Class</code> array
  5. * indicating the requested types
  6. * @return the object fetched that is the first match of the type
  7. * specified in the classes array. null if none of
  8. * the requested types are supported.
  9. * The <code>instanceof</code> operator should be used to
  10. * determine the specific kind of object returned.
  11. * @exception IOException if an I/O error occurs while
  12. * getting the content.
  13. * @exception UnknownServiceException if the protocol does not support
  14. * the content type.
  15. * @see java.net.URLConnection#getContent()
  16. * @see java.net.ContentHandlerFactory#createContentHandler(java.lang.String)
  17. * @see java.net.URLConnection#getContent(java.lang.Class[])
  18. * @see java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory)
  19. * @since 1.3
  20. */
  21. public Object getContent(Class[] classes) throws IOException {
  22. // Must call getInputStream before GetHeaderField gets called
  23. // so that FileNotFoundException has a chance to be thrown up
  24. // from here without being caught.
  25. getInputStream();
  26. return getContentHandler().getContent(this, classes);
  27. }

代码示例来源:origin: org.apidesign.bck2brwsr/emul

  1. /**
  2. * Retrieves the contents of this URL connection.
  3. *
  4. * @param classes the <code>Class</code> array
  5. * indicating the requested types
  6. * @return the object fetched that is the first match of the type
  7. * specified in the classes array. null if none of
  8. * the requested types are supported.
  9. * The <code>instanceof</code> operator should be used to
  10. * determine the specific kind of object returned.
  11. * @exception IOException if an I/O error occurs while
  12. * getting the content.
  13. * @exception UnknownServiceException if the protocol does not support
  14. * the content type.
  15. * @see java.net.URLConnection#getContent()
  16. * @see java.net.ContentHandlerFactory#createContentHandler(java.lang.String)
  17. * @see java.net.URLConnection#getContent(java.lang.Class[])
  18. * @see java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory)
  19. * @since 1.3
  20. */
  21. public Object getContent(Class[] classes) throws IOException {
  22. // Must call getInputStream before GetHeaderField gets called
  23. // so that FileNotFoundException has a chance to be thrown up
  24. // from here without being caught.
  25. getInputStream();
  26. return getContentHandler().getContent(this, classes);
  27. }

代码示例来源:origin: jtulach/bck2brwsr

  1. return getContentHandler().getContent(this);

代码示例来源:origin: org.apidesign.bck2brwsr/emul

  1. return getContentHandler().getContent(this);

代码示例来源:origin: com.gluonhq/robovm-rt

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException
  11. * if an error occurs obtaining the content.
  12. */
  13. public Object getContent() throws java.io.IOException {
  14. if (!connected) {
  15. connect();
  16. }
  17. if ((contentType = getContentType()) == null) {
  18. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  19. contentType = guessContentTypeFromStream(getInputStream());
  20. }
  21. }
  22. if (contentType != null) {
  23. return getContentHandler(contentType).getContent(this);
  24. }
  25. return null;
  26. }

代码示例来源:origin: com.jtransc/jtransc-rt

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException if an error occurs obtaining the content.
  11. */
  12. public Object getContent() throws java.io.IOException {
  13. if (!connected) {
  14. connect();
  15. }
  16. if ((contentType = getContentType()) == null) {
  17. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  18. contentType = guessContentTypeFromStream(getInputStream());
  19. }
  20. }
  21. if (contentType != null) {
  22. return getContentHandler(contentType).getContent(this);
  23. }
  24. return null;
  25. }

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException
  11. * if an error occurs obtaining the content.
  12. */
  13. public Object getContent() throws java.io.IOException {
  14. if (!connected) {
  15. connect();
  16. }
  17. if ((contentType = getContentType()) == null) {
  18. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  19. contentType = guessContentTypeFromStream(getInputStream());
  20. }
  21. }
  22. if (contentType != null) {
  23. return getContentHandler(contentType).getContent(this);
  24. }
  25. return null;
  26. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException
  11. * if an error occurs obtaining the content.
  12. */
  13. public Object getContent() throws java.io.IOException {
  14. if (!connected) {
  15. connect();
  16. }
  17. if ((contentType = getContentType()) == null) {
  18. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  19. contentType = guessContentTypeFromStream(getInputStream());
  20. }
  21. }
  22. if (contentType != null) {
  23. return getContentHandler(contentType).getContent(this);
  24. }
  25. return null;
  26. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException
  11. * if an error occurs obtaining the content.
  12. */
  13. public Object getContent() throws java.io.IOException {
  14. if (!connected) {
  15. connect();
  16. }
  17. if ((contentType = getContentType()) == null) {
  18. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  19. contentType = guessContentTypeFromStream(getInputStream());
  20. }
  21. }
  22. if (contentType != null) {
  23. return getContentHandler(contentType).getContent(this);
  24. }
  25. return null;
  26. }

代码示例来源:origin: com.jtransc/jtransc-rt

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type. The content type must match with one of
  8. * the list {@code types}.
  9. *
  10. * @param types the list of acceptable content types.
  11. * @return the content representing object or {@code null} if the content
  12. * type does not match with one of the specified types.
  13. * @throws IOException if an error occurs obtaining the content.
  14. */
  15. // Param is not generic in spec
  16. @SuppressWarnings("unchecked")
  17. public Object getContent(Class[] types) throws IOException {
  18. if (!connected) {
  19. connect();
  20. }
  21. if ((contentType = getContentType()) == null) {
  22. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  23. contentType = guessContentTypeFromStream(getInputStream());
  24. }
  25. }
  26. if (contentType != null) {
  27. return getContentHandler(contentType).getContent(this, types);
  28. }
  29. return null;
  30. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException
  11. * if an error occurs obtaining the content.
  12. */
  13. public Object getContent() throws java.io.IOException {
  14. if (!connected) {
  15. connect();
  16. }
  17. if ((contentType = getContentType()) == null) {
  18. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  19. contentType = guessContentTypeFromStream(getInputStream());
  20. }
  21. }
  22. if (contentType != null) {
  23. return getContentHandler(contentType).getContent(this);
  24. }
  25. return null;
  26. }

代码示例来源:origin: com.gluonhq/robovm-rt

  1. return getContentHandler(contentType).getContent(this, types);

代码示例来源:origin: FlexoVM/flexovm

  1. /**
  2. * Returns an object representing the content of the resource this {@code
  3. * URLConnection} is connected to. First, it attempts to get the content
  4. * type from the method {@code getContentType()} which looks at the response
  5. * header field "Content-Type". If none is found it will guess the content
  6. * type from the filename extension. If that fails the stream itself will be
  7. * used to guess the content type.
  8. *
  9. * @return the content representing object.
  10. * @throws IOException
  11. * if an error occurs obtaining the content.
  12. */
  13. public Object getContent() throws java.io.IOException {
  14. if (!connected) {
  15. connect();
  16. }
  17. if ((contentType = getContentType()) == null) {
  18. if ((contentType = guessContentTypeFromName(url.getFile())) == null) {
  19. contentType = guessContentTypeFromStream(getInputStream());
  20. }
  21. }
  22. if (contentType != null) {
  23. return getContentHandler(contentType).getContent(this);
  24. }
  25. return null;
  26. }

代码示例来源:origin: MobiVM/robovm

  1. return getContentHandler(contentType).getContent(this, types);

代码示例来源:origin: ibinti/bugvm

  1. return getContentHandler(contentType).getContent(this, types);

代码示例来源:origin: FlexoVM/flexovm

  1. return getContentHandler(contentType).getContent(this, types);

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

  1. return getContentHandler(contentType).getContent(this, types);

代码示例来源:origin: com.bugvm/bugvm-rt

  1. return getContentHandler(contentType).getContent(this, types);

相关文章

URLConnection类方法