Java 如何从列表中提取数据?

Java 如何从列表中提取数据?,java,android,tweets,Java,Android,Tweets,我正在开发一个Android应用程序,我想识别标签、提及和链接。我有一个可以在objective-c中使用的代码,它符合我的建议。我提出问题,现在我有了这些代码: import java.net.URL; import java.util.List; String input = /* text from edit text */; String[] words = input.split("\\s"); List<URL> urls=null; for (String s :

我正在开发一个Android应用程序,我想识别标签、提及和链接。我有一个可以在objective-c中使用的代码,它符合我的建议。我提出问题,现在我有了这些代码:

import java.net.URL;
import java.util.List;

String input = /* text from edit text */;

String[] words = input.split("\\s");
List<URL> urls=null;

for (String s : words){
try 
{
    urls.add(new URL(s));
}
catch (MalformedURLException e) {
    // not a url
}

}
但在推文中出现“使用我的appnull”

我如何重用此代码来识别哈希标记和提及?

//I test these
String tweet="Using my app"+urls
I think that is changing the input.split("\\s") by "@\\s" or "#\\s"

你可以在这里使用图书馆:
这就是你想要做的

比重新发明轮子要好得多。