Author: nextgens
Date: 2007-04-24 20:31:30 +0000 (Tue, 24 Apr 2007)
New Revision: 12929

Modified:
   trunk/freenet/src/freenet/support/io/FileUtil.java
Log:
I forgot one file :<

Modified: trunk/freenet/src/freenet/support/io/FileUtil.java
===================================================================
--- trunk/freenet/src/freenet/support/io/FileUtil.java  2007-04-24 20:30:18 UTC 
(rev 12928)
+++ trunk/freenet/src/freenet/support/io/FileUtil.java  2007-04-24 20:31:30 UTC 
(rev 12929)
@@ -3,8 +3,12 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.support.io;

+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStreamReader;

 final public class FileUtil {

@@ -56,7 +60,7 @@
                }
        }

-       public static File getCanonicalFile(File file){
+       public static File getCanonicalFile(File file) {
                File result;
                try {
                        result = file.getCanonicalFile();
@@ -65,4 +69,33 @@
                }
                return result;
        }
+       
+       public static String readUTF(File file) throws FileNotFoundException, 
IOException {
+               StringBuffer result = new StringBuffer();
+               FileInputStream fis = null;
+               BufferedInputStream bis = null;
+               InputStreamReader isr = null;
+               
+               try {
+                       fis = new FileInputStream(file);
+                       bis = new BufferedInputStream(fis);
+                       isr = new InputStreamReader(bis);
+
+                       char[] buf = new char[4096];
+                       int length = 0;
+                       
+                       while(length != -1) {
+                               length = isr.read(buf);
+                               result.append(buf, 0, length);
+                       }
+
+               } finally {
+                       try {
+                               if(isr != null) isr.close();
+                               if(bis != null) bis.close();
+                               if(fis != null) fis.close();
+                       } catch (IOException e) {}
+               }
+               return result.toString();
+       }
 }


Reply via email to