1 19 package org.netbeans.modules.j2ee.refactoring.test.util; 20 21 import org.openide.ErrorManager; 22 23 import javax.swing.*; 24 import java.io.File ; 25 import java.io.FileReader ; 26 import java.io.IOException ; 27 28 public class Helper { 29 30 31 public static String readFileContent(File f) throws IOException { 32 StringBuffer sb = new StringBuffer (); 33 FileReader fileReader = new FileReader (f); 34 int i; 35 while ((i = fileReader.read()) != -1) { 36 sb.append((char) i); 37 } 38 return sb.toString(); 39 } 40 41 public static void waitForAWTDispatchThread() { 42 final boolean[] finished = new boolean[]{false}; 43 SwingUtilities.invokeLater(new Runnable () { 44 public void run() { 45 finished[0] = true; 46 } 47 }); 48 while (!finished[0]) { 49 try { 50 Thread.sleep(200); 51 } catch (Exception e) { 52 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e); 53 } 54 } 55 } 56 } 57 | Popular Tags |