这是我读取文件和写入文件的代码;我想将字符串内容写入文本文件的末尾。我的目标是在文本文件中对光标移动/控制进行命令。
请帮帮我谢谢
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Filing {
public static void main(String[] args) throws IOException
{
String content = "This is the content to write into file";
BufferedReader br =
new BufferedReader(new FileReader("C:/Users/Ashad/Desktop/text.txt"));
try {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
FileWriter fw = new FileWriter("C:/Users/Ashad/Desktop/text.txt");
BufferedWriter bw = new BufferedWriter(fw);
while (line != null)
{
sb.append(line);
sb.append("\n");
line = br.readLine();
}
//** bw.write(content) ; **//
String everything = sb.toString();
System.out.append(everything);
}
finally
{ br.close();}
在文件中已经存在文本之后,我无法编写字符串内容。