java - 安卓 : openConnection() throws IOExeption ( Unable to find default handler for protocol: http )

标签 java android jcifs

我有一个使用 jcifs 库的 android 应用程序。每次我尝试使用 HTTP 协议(protocol)在 URL 上运行 openConnection() 时,我都会收到带有以下消息的 IOExeption:“无法找到协议(protocol)的默认处理程序:http”。它适用于使用 FTP 协议(protocol)的 URL。

经过一番挖掘,我怀疑问题出在 jcifs 库中。从 JCIFS 文档中,我发现了以下内容:

The jCIFS NTLM support is implemented as a URLStreamHandler for HTTP connections. This handler "wraps" the default handler provided by your Java environment to add support for NTLM authentication.

Add the "jcifs" package to the list of protocol handler packages. The "java.protocol.handler.pkgs" property is a pipe-separated ("|") list of packages which supply protocol handlers to Java.The "jcifs" package should be added to this list; this would typically be done by adding "-Djava.protocol.handler.pkgs=jcifs" to the command line when starting the application...

see full article

任何人都可以帮助解决这个问题。

最佳答案

尝试添加这个:

jcifs.Config.registerSmbURLHandler();

在您创建连接之前。这将在您的项目中安装 jcifs 包。

关于java - 安卓 : openConnection() throws IOExeption ( Unable to find default handler for protocol: http ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17485724/

相关文章:

java - 将 SmbFile 转换为 Java 文件

java - Android JCIF SMB

java - Spring Controller 中的BeanCreationException

java - 什么控制着 Tomcat 应用程序 URL 的第一部分?

java - Android 日期选择器监听器不能工作超过一次..

android - 在Android应用程序开发中将OpenCV与NDK结合使用

java - 使用 Handler 在 EDT 和其他 Java 线程之间传递信息

带有未转义引号的 Java CSV 解析器

android - 拆分 ActionBar 中的 withText

java - 如何在 JCIFS 中设置 DosFileFilter 以多个扩展名作为通配符?