[pkg-java] r4347 - trunk/checkstyle/debian

paulcager-guest at alioth.debian.org paulcager-guest at alioth.debian.org
Thu Oct 11 21:20:21 UTC 2007


Author: paulcager-guest
Date: 2007-10-11 21:20:21 +0000 (Thu, 11 Oct 2007)
New Revision: 4347

Modified:
   trunk/checkstyle/debian/Native2Ascii.java
Log:
Make sure Native2Ascii write out its buffer

Modified: trunk/checkstyle/debian/Native2Ascii.java
===================================================================
--- trunk/checkstyle/debian/Native2Ascii.java	2007-10-11 20:23:24 UTC (rev 4346)
+++ trunk/checkstyle/debian/Native2Ascii.java	2007-10-11 21:20:21 UTC (rev 4347)
@@ -266,33 +266,41 @@
     
     private void process(File srcFile, File destFile) throws BuildException
     {
-    	try
-    	{
-			BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(srcFile), encoding));
-			BufferedWriter bw = new BufferedWriter(new FileWriter(destFile));
-			
-			String line;
-			int ch;
-			while ( (ch = br.read()) != -1)
-			{
-				if (ch < 128)
-				{
-					bw.write(ch);
-				}
-				else
-				{
-					bw.write("\\u");
-					if (ch < 0x1000) bw.write('0');
-					if (ch < 0x100) bw.write('0');
-					if (ch < 0x10) bw.write('0');		// Never will be!
-					bw.write(Integer.toHexString(ch));
-				}
-			}
-		}
-    	catch (Exception e)
-    	{
-			throw new BuildException(e);
-		}
+        BufferedReader br = null;
+        BufferedWriter bw = null;
+
+        try
+        {
+            br = new BufferedReader(new InputStreamReader(new FileInputStream(srcFile), encoding));
+            bw = new BufferedWriter(new FileWriter(destFile));
+            
+            String line;
+            int ch;
+            while ( (ch = br.read()) != -1)
+            {
+                if (ch < 128)
+                {
+                    bw.write(ch);
+                }
+                else
+                {
+                    bw.write("\\u");
+                    if (ch < 0x1000) bw.write('0');
+                    if (ch < 0x100) bw.write('0');
+                    if (ch < 0x10) bw.write('0');        // Never will be!
+                    bw.write(Integer.toHexString(ch));
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            throw new BuildException(e);
+        }
+	finally
+	{
+            if (bw != null) try { bw.close(); } catch (Exception e) { throw new BuildException(e); }
+            if (br != null) try { br.close(); } catch (Exception e) { throw new BuildException(e); }
+	}
     }
 
     /**




More information about the pkg-java-commits mailing list