Java 从下载的文件中提取字符串

Java 从下载的文件中提取字符串,java,Java,我需要一些帮助来编辑字符串并将该字符串的部分添加到字符串的ArrayList: public ArrayList<String> strings = new ArrayList<String>(); 我只想将website=之后的部分添加到字符串数组中,我还想考虑website部分在那里,因为除了website=之外,我还有其他东西,比如ping=。我只是不知道我该怎么做 如果有人能在这方面帮助我,或者解释一种更好的方法,我可以自己做洞法,这将对我有很大帮助。那么你把所

我需要一些帮助来编辑字符串并将该字符串的部分添加到字符串的
ArrayList

public ArrayList<String> strings = new ArrayList<String>();
我只想将
website=
之后的部分添加到字符串数组中,我还想考虑
website
部分在那里,因为除了
website=
之外,我还有其他东西,比如
ping=
。我只是不知道我该怎么做


如果有人能在这方面帮助我,或者解释一种更好的方法,我可以自己做洞法,这将对我有很大帮助。

那么你把所有这些都放在一个字符串中了?然后正则表达式可能是一种方法,例如
Pattern
Matcher
以及表达式
website=(\S+)

例如:

String input = "website=http://google.com ping=http://pong.com website=http://stackoverflow.com";

Pattern p = Pattern.compile( "website=(\\S+)" );
Matcher m = p.matcher( input );

while( m.find() )
{
  System.out.println(m.group(1));
}
输出:

http://google.com
http://stackoverflow.com

没有单一的方法,但您可以使用以下方法: 1.函数:使用此函数查看字符串是否包含子字符串。要考虑到案例敏感性,您可以使用:

str = "website="
yourString.toLowerCase().contains(str.toLowerCase())
您可以与
if
逻辑组合,如:

if(yourString.toLowerCase().contains(str.toLowerCase())
//do something
您可以获得以下字符的索引
website=
like:

str="website=";
int index = yourString.indexOf(str)+str.length();

使用以上所有内容为您的需求编写一个逻辑。

网站=和ping=将如何分离?
str="website=";
int index = yourString.indexOf(str)+str.length();