Release opened resources properly
PR: MAVEN-402 git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113355 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -609,17 +609,22 @@ public class CodeTransform implements Serializable
|
||||
//make sure that the parent directories exist...
|
||||
new File(new File(destfile).getParent()).mkdirs();
|
||||
|
||||
BufferedReader in = new BufferedReader(new FileReader(sourcefile));
|
||||
;
|
||||
PrintWriter out = new PrintWriter(new FileWriter(destfile));
|
||||
FileReader fr = null;
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
fr = new FileReader(sourcefile);
|
||||
fw = new FileWriter(destfile);
|
||||
BufferedReader in = new BufferedReader(fr);
|
||||
|
||||
PrintWriter out = new PrintWriter(fw);
|
||||
|
||||
String line = "";
|
||||
String line = "";
|
||||
|
||||
out.println(getHeader());
|
||||
out.println(getHeader());
|
||||
|
||||
int linenumber = 1;
|
||||
while ((line = in.readLine()) != null)
|
||||
{
|
||||
int linenumber = 1;
|
||||
while ((line = in.readLine()) != null)
|
||||
{
|
||||
if (LINE_NUMBERS)
|
||||
{
|
||||
out.print("<a name=\"" + linenumber + "\" " +
|
||||
@@ -631,10 +636,26 @@ public class CodeTransform implements Serializable
|
||||
out.println(this.syntaxHighlight(line));
|
||||
|
||||
++linenumber;
|
||||
}
|
||||
}
|
||||
|
||||
out.println(getFooter());
|
||||
out.flush();
|
||||
out.println(getFooter());
|
||||
out.flush();
|
||||
} finally {
|
||||
if (fr != null) {
|
||||
try {
|
||||
fr.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (fw != null) {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user