1 package org.columba.mail.folder; 19 20 import java.io.BufferedReader ; 21 import java.io.ByteArrayInputStream ; 22 import java.io.File ; 23 import java.io.InputStream ; 24 import java.io.InputStreamReader ; 25 26 import org.columba.core.io.DiskIO; 27 28 33 public final class FolderTstHelper { 34 35 38 public static String homeDirectory = System.getProperties().getProperty( 39 "user.dir"); 40 41 49 public static String getString(int number) throws Exception { 50 return DiskIO.readFileInString(new File (new String ( 51 "mail/src/test/java/org/columba/mail/folder/" + number + ".eml"))).replaceAll("\n", "\r\n"); 52 } 53 54 61 public static String getString(String filename) throws Exception { 62 return DiskIO.readFileInString(new File (new String ( 63 "mail/src/test/java/org/columba/mail/folder/" + filename))).replaceAll("\n", "\r\n"); 64 } 65 66 73 public static ByteArrayInputStream getByteArrayInputStream(String s) { 74 return new ByteArrayInputStream (s.getBytes()); 75 } 76 77 85 public static String getStringFromInputStream(InputStream is) 86 throws Exception { 87 StringBuffer result = new StringBuffer (); 88 BufferedReader reader = new BufferedReader (new InputStreamReader (is)); 89 String nextLine = reader.readLine(); 90 91 while (nextLine != null) { 92 result.append(nextLine); 93 result.append("\r\n"); 94 nextLine = reader.readLine(); 95 } 96 97 return result.toString(); 98 } 99 } 100 | Popular Tags |