1 19 package org.netbeans.modules.j2ee.websphere6.util; 20 21 import java.io.*; 22 23 import org.openide.*; 24 25 30 public class WSUtil { 31 32 private static Class clazz = new WSUtil().getClass(); 33 34 40 public static String readFile(File file) { 41 StringBuffer buffer = new StringBuffer (); 43 44 try { 45 LineNumberReader reader = new LineNumberReader(new FileReader(file)); 47 48 String temp = ""; 50 51 while ((temp = reader.readLine()) != null) { 53 buffer.append(temp).append("\n"); 54 } 55 56 if (WSDebug.isEnabled()) 57 WSDebug.notify(clazz, "read string: \n" + buffer.toString()); 58 59 return buffer.toString(); 61 } catch (IOException e) { 62 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e); 63 } 64 65 return null; 66 } 67 68 74 public static void writeFile(File file, String contents) { 75 try { 76 if (WSDebug.isEnabled()) 77 WSDebug.notify(clazz, "write string: \n" + contents); 78 79 new FileOutputStream(file).write(contents.getBytes()); 81 } catch (IOException e) { 82 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e); 83 } 84 } 85 } | Popular Tags |