Java 写问题,修改文件中某段数据

String path="**";
BufferedReader reader = null;
BufferedWriter writer = null;
try {
    reader = new BufferedReader(new FileReader(path));
    StringBuilder context=new StringBuilder();
    String str = "";
    while (null != (str = reader.readLine())) {
        if (str.contains("DBPassword")) {
            str = "DBPassword=" + password(unipd加密);
        }
        log.info("确认过眼神:" + str);
        context.append(str).append("\n");
    }
writer = new BufferedWriter(new FileWriter(path));
writer.write(context.toString());

你可能感兴趣的:(Java)