1 25 26 package org.nemesis.forum.util; 27 28 import java.io.IOException ; 29 import java.io.Writer ; 30 31 38 public class UnicodeFilterWriter extends Writer { 39 40 private Writer out; 42 43 48 public UnicodeFilterWriter( Writer out ) { 49 super(out); 50 this.out = out; 51 } 52 53 62 public void write(char[] cbuf, int offset, int length) throws IOException { 63 synchronized( lock ) { 64 int loopEnd = (offset+length); 65 for( int i=offset; i<loopEnd; i++ ) { 66 switch(cbuf[i]) { 67 case '\u0000': 69 break; 70 case '\u0018': 71 break; 72 default: 74 out.write(cbuf[i]); 75 break; 76 } 77 } 78 } 79 } 80 81 84 public void flush() throws IOException { 85 synchronized (lock) { 86 out.flush(); 87 } 88 } 89 90 93 public void close() throws IOException { 94 synchronized (lock) { 95 if (out == null) { 96 return; 97 } 98 out.close(); 99 out = null; 100 } 101 } 102 103 } 104 | Popular Tags |