[Schmitzm-commits] r595 - branches/1.0-gt2-2.6/src/schmitzm/io
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat Nov 28 02:12:42 CET 2009
Author: alfonx
Date: 2009-11-28 02:12:42 +0100 (Sat, 28 Nov 2009)
New Revision: 595
Modified:
branches/1.0-gt2-2.6/src/schmitzm/io/IOUtil.java
Log:
* added utility method readFileAsString
Modified: branches/1.0-gt2-2.6/src/schmitzm/io/IOUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/io/IOUtil.java 2009-11-28 01:12:21 UTC (rev 594)
+++ branches/1.0-gt2-2.6/src/schmitzm/io/IOUtil.java 2009-11-28 01:12:42 UTC (rev 595)
@@ -608,4 +608,21 @@
return true;
}
+ /**
+ * Reads the contents of a File into one String. Watch the size!
+ *
+ * @param file
+ * a File to read
+ * @return as String the content of the file.
+ *
+ * @throws java.io.IOException
+ */
+ public static String readFileAsString(File file) throws java.io.IOException {
+ byte[] buffer = new byte[(int) file.length()];
+ FileInputStream f = new FileInputStream(file);
+ f.read(buffer);
+ return new String(buffer);
+ }
+
+
}
More information about the Schmitzm-commits
mailing list