我使用此代碼片段從網頁中讀取文本並將其保存爲字符串?如何重置BufferedReader(或InputStreamReader)以使用readline()兩次?
我想readline()函數從開始。所以它會再次讀取網頁的內容。我該怎麼做
if (response == httpURLConnection.HTTP_OK) {
in = httpURLConnection.getInputStream();
isr = new InputStreamReader(in);
br = new BufferedReader(isr);
while ((line = br.readLine()) != null) {
fullText += line;
}
// I want to go through a webpage source again, but
// I can't because br.readLine() = null. How can I put
// put a marker on the beginning of the page?
while ((line1 = br.readLine()) != null) {
fullText1 += line1;
// It will not go into this loop
}
@JeanJung - 隨着OP的方式構建'fullText',它沒有任何換行符。 –