我有這個Java代碼,我想返回2個值,然後在main()或其他函數中使用它們。請幫助一些。 TX:Java - 返回2值(字符串數組)
import java.net.*;
import java.io.*;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
public class URLReader {
public String[] functie(String x) throws Exception
{
URL oracle = new URL(x);
BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
String inputLine=null;
StringBuffer theText = new StringBuffer();
while ((inputLine = in.readLine()) != null)
theText.append(inputLine+"\n");
String html = theText.toString();
in.close();
String[] tds = StringUtils.substringsBetween(html, "<tr>", "</tr>");
String[] tds2 = StringUtils.substringsBetween(tds[1], "href=\"/module/gallery", "\"><img");
String[] tds3 = StringUtils.substringsBetween(tds[1], "src='/redx_tools/mb_image.php", "' border='1'");
return ???
}
public static void main(String[] args) throws Exception {
String x = new String("http://www.wippro.at/module/gallery/index.php?limitstart=0&picno=0&gallery_key=59");
URLReader s = new URLReader();
for (String st : s.functie(x))
{
System.out.println(st);
}
}
}
向量被認爲是不推薦的,ArrayList應該在大多數情況下使用。 –
我使用Vector時,我希望它可以在所有JVM上工作,無論它們多大。只插入2個條目(甚至是2打)時,同步開銷顯然不是問題。 –