tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r930395 - /tuscany/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java
Date Fri, 02 Apr 2010 21:32:04 GMT
Author: rfeng
Date: Fri Apr  2 21:32:03 2010
New Revision: 930395

URL: http://svn.apache.org/viewvc?rev=930395&view=rev
Log:
Close the file handle after reading the content

Modified:
    tuscany/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java

Modified: tuscany/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java?rev=930395&r1=930394&r2=930395&view=diff
==============================================================================
--- tuscany/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java
(original)
+++ tuscany/maven-plugins/trunk/maven-eclipse-compiler/src/main/java/org/apache/tuscany/maven/compiler/FileCompilationUnit.java
Fri Apr  2 21:32:03 2010
@@ -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
  * @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 ICo
         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 ICo
                 }
                 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 ICo
     }
 
     public char[] getFileName() {
-        return (className.replace('.', fileSeparator) + ".java").toCharArray();
+        return (className.replace('.', File.separatorChar) + ".java").toCharArray();
     }
 
     public char[] getMainTypeName() {



Mime
View raw message