Java替换文本文件中的行
如何替换文本文件中找到的文本行?
我有一个字符串,如:
Do the dishes0
我想用以下内容更新它:
Do the dishes1
(反之亦然)
我该如何做到这一点?
ActionListener al = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox checkbox = (JCheckBox) e.getSource();
if (checkbox.isSelected()) {
System.out.println("Selected");
String s = checkbox.getText();
replaceSelected(s, "1");
} else {
System.out.println("Deselected");
String s = checkbox.getText();
replaceSelected(s, "0");
}
}
};public static void replaceSelected(String replaceWith, String type) {}顺便说一句,我想只替换读取的行。不是整个文件。
子衿沉夜
随时随地看视频慕课网APP
相关分类