[jboss-svn-commits] JBL Code SVN: r5694 - in labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/jboss/loanbroker: . util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 10 02:38:20 EDT 2006
Author: daniel.brum at jboss.com
Date: 2006-08-10 02:38:19 -0400 (Thu, 10 Aug 2006)
New Revision: 5694
Added:
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/jboss/loanbroker/util/
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/jboss/loanbroker/util/FileUtil.java
Log:
Added: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/jboss/loanbroker/util/FileUtil.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/jboss/loanbroker/util/FileUtil.java 2006-08-10 06:38:15 UTC (rev 5693)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/jboss/loanbroker/util/FileUtil.java 2006-08-10 06:38:19 UTC (rev 5694)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.jboss.loanbroker.util;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+/**
+ * Utility class for reading a file into a String and back.
+ * @author kstam
+ */
+public class FileUtil {
+ /**
+ * Read the file into a String.
+ * @param file - the file to be read
+ * @return String with the content of the file
+ * @throws IOException - when we can't read the file
+ */
+ public static String readTextFile(File file) throws IOException
+ {
+ StringBuffer sb = new StringBuffer(1024);
+ BufferedReader reader = new BufferedReader(new FileReader(file.getPath()));
+ char[] chars = new char[1];
+ while( (reader.read(chars)) > -1){
+ sb.append(String.valueOf(chars));
+ chars = new char[1];
+ }
+ reader.close();
+ return sb.toString();
+ }
+ /**
+ * Write a String into a file.
+ * @param file - File to which we write the String
+ * @param str - string which will be written
+ * @throws IOException - when we can't write to the file
+ */
+ public static void writeTextFile(File file, String str) throws IOException
+ {
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file.getPath()));
+ writer.write(str);
+ writer.close();
+ }
+
+}
More information about the jboss-svn-commits
mailing list