📄 writetxt.java
字号:
import java.io.File;
import java.io.FileOutputStream;
public class Writetxt {
public void DOWriteTxt(String file, String txt) {
try {
//写入文件尾
FileOutputStream os = new FileOutputStream(new File(file), true);
//覆盖
//FileOutputStream os = new FileOutputStream(new File(file), false);
//os.write((txt + "\n").getBytes());
//这里不需要换行,换行另处理
os.write((txt).getBytes());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new Writetxt().DOWriteTxt("D:\\问好.txt", "你好!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -