* @return the {@code File} instance of the ruleset file.
* @throws CoreException
*/
private File writeRuleSet(final IFile rulesetFile, final RuleSet ruleSet,
final IProgressMonitor monitor) throws CoreException {
final PMDPlugin pmdPlugin = PMDPlugin.getDefault();
BufferedOutputStream outputStream = null;
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
try {
outputStream = new BufferedOutputStream(new FileOutputStream(
rulesetFile.getLocation().toFile()));
pmdPlugin.getRuleSetWriter().write(byteArrayStream, ruleSet);
// ..and now we have two problems
String fixedXml = byteArrayStream.toString()
.replaceAll("\\<exclude\\>(.*)\\</exclude\\>",
"<exclude name=\"$1\"/>");