2012-02-21 76 views

回答

0

假设你的意思是:

String links = "http://www.website1.com/thistext\n" + 
       "http://www.website1.com/othertext\n" + 
       "http://www.website1.com/thistext"; 

然后,你可以这样做:

public static void main(String[] args) { 
    String links = "http://www.website1.com/thistext\n" + 
        "http://www.website1.com/othertext\n" + 
        "http://www.website1.com/thistext"; 
    String[] linksArray = links.split("\n"); 

    for (String link : linksArray) { 
     if (link.contains("thistext")) { 
      System.out.println(link); 
     } 
    } 

} 
0

首先使用一个很好的分隔符为您的链接,如逗号,分号或其他。使用字符串标记器获取各个链接,最后使用indexOf在每个标记化字符串中搜索您的术语,即“thisText”。这将为你完成这项工作。

相关问题