1 17 package javax.servlet; 18 19 import java.io.OutputStream ; 20 import java.io.IOException ; 21 import java.io.CharConversionException ; 22 import java.text.MessageFormat ; 23 import java.util.ResourceBundle ; 24 25 42 43 public abstract class ServletOutputStream extends OutputStream { 44 45 private static final String LSTRING_FILE = "javax.servlet.LocalStrings"; 46 private static ResourceBundle lStrings = 47 ResourceBundle.getBundle(LSTRING_FILE); 48 49 50 51 56 57 protected ServletOutputStream() { } 58 59 60 71 72 public void print(String s) throws IOException { 73 if (s==null) s="null"; 74 int len = s.length(); 75 for (int i = 0; i < len; i++) { 76 char c = s.charAt (i); 77 78 if ((c & 0xff00) != 0) { String errMsg = lStrings.getString("err.not_iso8859_1"); 86 Object [] errArgs = new Object [1]; 87 errArgs[0] = new Character (c); 88 errMsg = MessageFormat.format(errMsg, errArgs); 89 throw new CharConversionException (errMsg); 90 } 91 write (c); 92 } 93 } 94 95 96 97 108 109 public void print(boolean b) throws IOException { 110 String msg; 111 if (b) { 112 msg = lStrings.getString("value.true"); 113 } else { 114 msg = lStrings.getString("value.false"); 115 } 116 print(msg); 117 } 118 119 120 121 131 132 public void print(char c) throws IOException { 133 print(String.valueOf(c)); 134 } 135 136 137 138 139 150 151 public void print(int i) throws IOException { 152 print(String.valueOf(i)); 153 } 154 155 156 157 158 170 171 public void print(long l) throws IOException { 172 print(String.valueOf(l)); 173 } 174 175 176 177 189 190 public void print(float f) throws IOException { 191 print(String.valueOf(f)); 192 } 193 194 195 196 207 208 public void print(double d) throws IOException { 209 print(String.valueOf(d)); 210 } 211 212 213 214 223 224 public void println() throws IOException { 225 print("\r\n"); 226 } 227 228 229 230 240 241 public void println(String s) throws IOException { 242 print(s); 243 println(); 244 } 245 246 247 248 249 262 263 public void println(boolean b) throws IOException { 264 print(b); 265 println(); 266 } 267 268 269 270 280 281 public void println(char c) throws IOException { 282 print(c); 283 println(); 284 } 285 286 287 288 299 300 public void println(int i) throws IOException { 301 print(i); 302 println(); 303 } 304 305 306 307 318 319 public void println(long l) throws IOException { 320 print(l); 321 println(); 322 } 323 324 325 326 339 340 public void println(float f) throws IOException { 341 print(f); 342 println(); 343 } 344 345 346 347 359 360 public void println(double d) throws IOException { 361 print(d); 362 println(); 363 } 364 } 365 | Popular Tags |