1 57 58 package org.apache.commons.jrcs.util; 59 60 import java.io.BufferedReader ; 61 import java.io.StringReader ; 62 import java.util.List ; 63 import java.util.LinkedList ; 64 65 71 public class ToString 72 { 73 public ToString() 74 { 75 } 77 78 84 public String toString() 85 { 86 StringBuffer s = new StringBuffer (); 87 toString(s); 88 return s.toString(); 89 } 90 91 95 public void toString(StringBuffer s) 96 { 97 s.append(super.toString()); 98 } 99 100 101 102 108 public static String [] stringToArray(String value) 109 { 110 BufferedReader reader = new BufferedReader (new StringReader (value)); 111 List l = new LinkedList (); 112 String s; 113 try 114 { 115 while ((s = reader.readLine()) != null) 116 { 117 l.add(s); 118 } 119 } 120 catch (java.io.IOException e) 121 { 122 } 124 return (String []) l.toArray(new String [l.size()]); 125 } 126 127 133 public static String arrayToString(Object [] o) 134 { 135 return arrayToString(o, System.getProperty("line.separator")); 136 } 137 138 144 public static String arrayToString(Object [] o, String EOL) 145 { 146 StringBuffer buf = new StringBuffer (); 147 for (int i = 0; i < o.length - 1; i++) 148 { 149 buf.append(o[i]); 150 buf.append(EOL); 151 } 152 buf.append(o[o.length - 1]); 153 return buf.toString(); 154 } 155 } 156 157 | Popular Tags |