Does the work.
if (cvsRoot == null) {
throw new BuildException("cvsroot is required");
}
if (password == null) {
throw new BuildException("password is required");
}
log("cvsRoot: " + cvsRoot, Project.MSG_DEBUG);
log("password: " + password, Project.MSG_DEBUG);
log("passFile: " + passFile, Project.MSG_DEBUG);
BufferedReader reader = null;
PrintWriter writer = null;
try {
StringBuffer buf = new StringBuffer();
if (passFile.exists()) {
reader = new BufferedReader(new FileReader(passFile));
String line = null;
while ((line = reader.readLine()) != null) {
if (!line.startsWith(cvsRoot)) {
buf.append(line).append(StringUtils.LINE_SEP);
}
}
}
String pwdfile = buf.toString() + cvsRoot + " A"
+ mangle(password);
log("Writing -> " + pwdfile , Project.MSG_DEBUG);
writer = new PrintWriter(new FileWriter(passFile));
writer.println(pwdfile);
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
if (writer != null) {
writer.close();
}
}