无法使用包 org.apache.commons.lang.StringUtils

发布于 2024-12-16 22:17:20 字数 952 浏览 1 评论 0原文

我是 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);
    }
}

I am new to Jdeveloper and I was writing a program which used text in between two strings. I stumbled upon StringUtils.substringBetween() function but when I compile the program it says it cannot find variable StringUtils and does not recognise org.apache.commons.lang.StringUtils package. Please do tell me where I am going wrong. One thing I thought was the package was missing from the libraries but since I am new I don't know how to install such a package or where to install for that matter. I am using jdev 10.1.3.5.0. The code I stumbled upon on the net is this:

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);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

昔日梦未散 2024-12-23 22:17:22

下载 commons-lang 并将其放入 /WEB-INF/lib 文件夹中。

如果它不是 Web 应用程序,您必须检查如何使用 JDeveloper 将其添加到构建路径中。

Download commons-lang and throw it into your /WEB-INF/lib folder.

If its not a web application you have to check how you can add it to your build path with JDeveloper.

贩梦商人 2024-12-23 22:17:22

添加 Apache Maven 库。这将解决问题
(项目属性 -> 库和类补丁 -> 添加库)。

Add Apache Maven library. This will resolves the issue
(project properties -> libraries and class patch -> add library).

诗笺 2024-12-23 22:17:20

从 apache jakarta sie 下载 apache-lang common:

http://commons.apache.org/lang/

获取 jar 文件后,请将此 jar 放在项目的构建路径中,如果您无法找到构建路径,请转到 Jdeveloper 帮助文件并输入“构建路径”,您将在那里得到所有的信任。

Download apache-lang common from apache jakarta sie:

http://commons.apache.org/lang/

After getting jar file please put this jar in your project's build path, if you are not able to find build path then go Jdeveloper help file and type "build path" and you will get all intrustion over there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文