问题描述
我正在尝试使用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();
}
我不确定为什么它不起作用,任何帮助将不胜感激
1楼
用作包装器,指示在静态初始值设定项块或对静态变量的值求值时发生异常。
因此,我们必须确保原始异常是固定的,以便JVM能够成功加载类。