我正在尝试使用samba从文件系统中读取xml文件。我的应用程序崩溃,唯一的错误是:
FATAL EXCEPTION: main Process: com.example.imac.chs_pharmacy, PID: 2615
java.lang.ExceptionInInitializerError
它在线上崩溃了:
SmbFileInputStream fXmlFile = new SmbFileInputStream(sFile);
我也使用过这一行,结果相同:
InputStream fXmlFile = sFile.getInputStream();
以下是我正在使用的代码段:
try {
String user = "user";
String pass ="pass";
String url = "smb://ip/public/chs/" + message + ".xml";
Log.d(TAG, url);
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, user, pass);
SmbFile sFile = new SmbFile(url, auth);
SmbFileInputStream fXmlFile = new SmbFileInputStream(sFile);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
}
我不确定为什么它不起作用,任何帮助都会受到赞赏
答案 0 :(得分:1)
java.lang.ExceptionInInitializerError
用作包装器,表示静态初始化程序块中出现异常或评估静态变量的值。
因此,我们必须确保修复原始异常,以便JVM能够成功加载类。