这个问题是关于lambda表达式似乎使用的Java包的明显"隐藏"或本地导入.
以下示例代码编译并运行正常(它只列出给定目录中的文件):
package com.mbm.stockbot;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Temp2 {
public static void main(String[] args) {
Temp2 t = new Temp2();
t.readDir();
}
public void readDir() {
try {
Files.walk(Paths.get("C:/Users/mbmas_000/Downloads/SEC Edgar"), 1).forEach(filePath -> {
if (Files.isRegularFile(filePath)) {
System.out.println(filePath);
}
});
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,该变量filePath是一个实例Path,我认为它的实现包含在包中java.nio.file.Path,尽管import该包没有.
现在,如果我做了一个小修改,可以通过重构System.out.println对它自己的方法的调用来说:
package com.mbm.stockbot;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Temp2 {
public …Run Code Online (Sandbox Code Playgroud) 我在解组某些 XML 时遇到问题。部分堆栈转储如下所示:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"properties"). Expected elements are (none)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:726)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:247)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:242)
Run Code Online (Sandbox Code Playgroud)
下面是我尝试解组的 XML、XJC 生成的根元素 Java 类、输入 XJC 的 XSD 以及最后 XJC 生成的 ObjectFactory。
我正在解组的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<properties program-name="EstateAccounting"
properties-file="EstateAccounting.properties">
<keyword-properties>
<keyword-property type="string" name="reportDirectory" alias="rd">
<description>
<![CDATA[Specifies the optional report directory. Double quotes are required if the report directory
contains spaces. The report directory specifies where the intermediate XML used to produce the PDF report
and where the PDF report should be …Run Code Online (Sandbox Code Playgroud)