正試圖修改現有的以下文件。使用java編輯或修改現有文件
User navigates to Facebook
Given I am on Facebook login page
Scenario: enter username as "TOM"
And I enter password as "JERRY"
Feature: annotation
Background:
User navigates to Facebook
Given I am on Facebook login page
But Relogin option should be available
我試着用下面的代碼和文件內容清除了!
public void addTags(File file) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
String line;
BufferedWriter bw = null;
FileWriter fw = null;
int count = 0;
while ((line = bufferedReader.readLine()) != null) {
fw = new FileWriter(file);
fw.write(line);
fw.write("\n");
fw.close();
}
bufferedReader.close();
}
請糾正我..我的代碼有什麼問題。
你在哪裏初始化的BufferedWriter? – Christian
[將字符串附加到基於特定字符串位置的文件]可能的重複(http://stackoverflow.com/questions/42129708/append-strings-to-a-file-based-on-a-particular-string-職位) – AxelH
我沒有看到與你在5小時前提出的其他問題的區別。 – AxelH