這裏一個空文件是我剛纔的問題的編輯版本:沒有任何內容
因此,這裏是我的目的:在一個.txt文件(HTML文件)中讀取,並把所需要的內容放到一個.txt文件。現在
,這個HTML文件中包含噸表格和格式的,我不需要,我只需要內容
import java.io.*;
public class File {
public static void main(String[] args) throws IOException
{
try{ String input = "out.txt";
BufferedReader in = new BufferedReader(new FileReader(input));
String output = "output.txt";
BufferedWriter out = new BufferedWriter(new FileWriter(output));
String inputLine = "";
int i=0;
while ((inputLine = in.readLine()) != null) {
if (inputLine.contains("Windows")) {
out.append(inputLine);
out.newLine();
}
in.close();
out.close();
}
}
它使一個名爲「output.txt的」文件,但它完全是空的。
它如何精確地排序字符串?是逐字逐句還是逐句句子?
以下是該文件的示例。 (有點)
<TR class="RowDark">
<TD width=0><A href="Report.asp?ReportID=100&sp=Service+Pack+1&os=Microsoft%28R%29+Windows%28R%29+Server+2003%2C+Enterprise+Edition"><IMG border=0 src="images/icolink3.gif" alt="Open the target" width=11 height=11></A></TD>
<TD class=SimpleTextSmall> Microsoft(R) Windows(R) Server 2003, Enterprise Edition </TD>
<TD class=SimpleTextSmall> Service Pack 1 </TD>
<TD class=SimpleTextSmall> 60 </TD>
</TR>
它可以執行它只是作爲Microsoft(R)Windows(R)服務器企業版,60嗎?
UPDATE:
它還執行 「喜」
你在哪裏閱讀.txt文件。我所看到的僅僅是桌面的路徑,而不是實際的文件。 – Jimmy
那這不是文件?我想如果你定義一個路徑,它會讀取文件 – ToxicGlow