1 57 58 package com.Yasna.util; 59 60 import java.io.*; 61 62 69 public class UnicodeFilterWriter extends Writer { 70 71 private Writer out; 73 74 79 public UnicodeFilterWriter( Writer out ) { 80 super(out); 81 this.out = out; 82 } 83 84 93 public void write(char[] cbuf, int offset, int length) throws IOException { 94 synchronized( lock ) { 95 int loopEnd = (offset+length); 96 for( int i=offset; i<loopEnd; i++ ) { 97 switch(cbuf[i]) { 98 case '\u0000': 100 break; 101 case '\u0018': 102 break; 103 default: 105 out.write(cbuf[i]); 106 break; 107 } 108 } 109 } 110 } 111 112 115 public void flush() throws IOException { 116 synchronized (lock) { 117 out.flush(); 118 } 119 } 120 121 124 public void close() throws IOException { 125 synchronized (lock) { 126 if (out == null) { 127 return; 128 } 129 out.close(); 130 out = null; 131 } 132 } 133 134 } 135 | Popular Tags |