我使用bufferedreader提取5個網頁,每個網頁用空格分隔,我想使用子字符串來提取每個網頁url,html,源和日期。但我需要指導如何正確使用子字符串來實現這一點,歡呼聲。嘗試從緩衝讀取器中提取子字符串,讀取某些標記
public static List<WebPage> readRawTextFile(Context ctx, int resId) {
InputStream inputStream = ctx.getResources().openRawResource(
R.raw.pages);
InputStreamReader inputreader = new InputStreamReader(inputStream);
BufferedReader buffreader = new BufferedReader(inputreader);
String line;
StringBuilder text = new StringBuilder();
try {
while ((line = buffreader.readLine()) != null) {
if (line.length() == 0) {
// ignore for now
//Will be used when blank line is encountered
}
if (line.length() != 0) {
//here I want the substring to pull out the correctStrings
int sURL = line.indexOf("<!--");
int eURL = line.indexOf("-->");
line.substring(sURL,eURL);
**//Problem is here**
}
}
} catch (IOException e) {
return null;
}
return null;
}
我想如何提取文本是這樣的地址我想刪除標籤<! - 地址:http://www.google.co.uk.html-->所以,我離開了有了這個,我可以存儲它:http://www.google.co.uk.html – rtkgpe
爲什麼你想要通過子串操作?只需使用String.replace()。 – Smit