diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-02 21:32:03 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-02 21:32:03 +0000 |
commit | 3b5d424c0ad96288d5e35089097f824b44507760 (patch) | |
tree | 4dc14a529f17e3b53d6d079ab248ef208821c863 /maven-plugins | |
parent | b11e2ee704563e82f8b981cbcc672c4fb65bbc80 (diff) |
Close the file handle after reading the content
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@930395 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'maven-plugins')
-rw-r--r-- | maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java b/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java index a3ee7af8f8..e3d7c94e97 100644 --- a/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java +++ b/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java @@ -20,6 +20,7 @@ package org.apache.tuscany.maven.compiler; import java.io.CharArrayWriter; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -34,7 +35,6 @@ import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; * @version $Rev$ $Date$ */ class FileCompilationUnit implements ICompilationUnit { - private final static char fileSeparator = System.getProperty("file.separator").charAt(0); private String className; private String sourceFile; @@ -47,7 +47,7 @@ class FileCompilationUnit implements ICompilationUnit { try { InputStreamReader reader = new InputStreamReader(new FileInputStream(sourceFile)); CharArrayWriter writer = new CharArrayWriter(); - char[] b = new char[2048]; + char[] b = new char[4096]; for (;;) { int n = reader.read(b); if (n <= 0) { @@ -55,6 +55,8 @@ class FileCompilationUnit implements ICompilationUnit { } writer.write(b, 0, n); } + // Let's close the file handle + reader.close(); return writer.toCharArray(); } catch (FileNotFoundException e) { @@ -65,7 +67,7 @@ class FileCompilationUnit implements ICompilationUnit { } public char[] getFileName() { - return (className.replace('.', fileSeparator) + ".java").toCharArray(); + return (className.replace('.', File.separatorChar) + ".java").toCharArray(); } public char[] getMainTypeName() { |