我是 Jdeveloper 的新手,我正在编写一个在两个字符串之间使用文本的程序。我偶然发现了 StringUtils.substringBetween()
函数,但是当我编译程序时它说找不到变量 StringUtils
并且无法识别 org.apache.commons.lang .StringUtils
包。请告诉我哪里出错了。我想到的一件事是库中缺少该软件包,但由于我是新手,所以我不知道如何安装这样的软件包或在何处安装。我正在使用 jdev 10.1.3.5.0。我在网上偶然发现的代码是这样的:
import java.util.Date;
import org.apache.commons.lang.StringUtils;
public class NestedString {
public static void main(String[] args) {
String helloHtml = "<html>" + "<head>" + " <title>Hello World from Java</title>"
+ "<body>" + "Hello, today is: " + new Date() + "</body>" + "</html>";
String title = StringUtils.substringBetween(helloHtml, "<title>", "</title>");
String content = StringUtils.substringBetween(helloHtml, "<body>", "</body>");
System.out.println("title = " + title);
System.out.println("content = " + content);
}
}
最佳答案
从 apache jakarta sie 下载 apache-lang common:
http://commons.apache.org/lang/
获取 jar 文件后,请将此 jar 放入项目的构建路径中,如果找不到构建路径,请转到 Jdeveloper 帮助文件并键入“构建路径”,您将在那里获得所有信任。
关于java - 无法使用包 org.apache.commons.lang.StringUtils,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8192442/