[Title] Added writeTextFile()
authorkh5325.kim <kh5325.kim@samsung.com>
Thu, 27 Oct 2011 01:03:11 +0000 (10:03 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Thu, 27 Oct 2011 01:03:11 +0000 (10:03 +0900)
[Type] Enhancement
[Module] common
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

com.samsung.slp.common/src/com/samsung/slp/common/util/BrowserWrapper.java
com.samsung.slp.common/src/com/samsung/slp/common/util/FileUtil.java

index 4fc3077..7719827 100644 (file)
@@ -58,4 +58,8 @@ public class BrowserWrapper {
     public void setFocus() {
         browser.setFocus();
     }
+
+    public Browser getBrowser() {
+        return browser;
+    }
 }
index 2c08072..0882496 100644 (file)
@@ -21,12 +21,15 @@ package com.samsung.slp.common.util;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
+import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.net.URI;
 
 import org.eclipse.core.filesystem.EFS;
@@ -44,6 +47,27 @@ public class FileUtil {
     private static final int BUFFER_SIZE = 8192;
 
     /**
+     * write text into given file
+     */
+    public static void writeTextFile(File file, String text, String encoding) throws IOException {
+        BufferedWriter out = null;
+    
+        if (encoding == null) { // if encoding is not set then use default encoding
+            encoding = System.getProperty("file.encoding");
+        }
+    
+        try {
+            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding), BUFFER_SIZE);
+            out.write(text.toCharArray(), 0, text.length());
+            out.flush();
+        } finally {
+            if (out != null) {
+                out.close();
+            }
+        }
+    }
+
+    /**
      *  read text from given file 
      */
     public static String readTextFile(File file, String encoding) throws IOException {