From 3b5d424c0ad96288d5e35089097f824b44507760 Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 2 Apr 2010 21:32:03 +0000 Subject: 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 --- .../org/apache/tuscany/maven/compiler/FileCompilationUnit.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'maven-plugins/trunk/maven-eclipse-compiler/src/main/java') 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() { -- cgit v1.2.3