我的问题是我如何才能通过一个字符串并只取出链接并删除所有其余部分?我考虑过使用某种类型的分隔符,但不知道如何在 Java 中使用它。我正在尝试做的一个例子:
这是我的字符串:
String myString = "The file is http: // www. .com/hello.txt and the second file is "
+ "http: // www. .com/hello2.dat";
我希望输出为:
"http: // www. .com/hello.txt http: // www. .com/hello2.dat"
或者每个都可以单独添加到数组中。我只是想要一些想法,我喜欢自己编写代码,但在如何做时遇到了麻烦。任何帮助都是极好的。