1 18 package net.sf.drftpd.util; 19 20 import java.io.IOException ; 21 import java.io.OutputStream ; 22 23 29 public class StripAsciiOutputStream extends OutputStream { 30 31 private OutputStream _out; 32 33 boolean _lastWasCarriageReturn = false; 34 35 public StripAsciiOutputStream(OutputStream out) { 36 _out = out; 37 } 38 39 public void write(int b) throws IOException { 40 if (b == '\r') { 41 _lastWasCarriageReturn = true; 42 return; 43 } 44 45 if (_lastWasCarriageReturn) { 46 _lastWasCarriageReturn = false; 47 if (b != '\n') { 48 _out.write('\r'); 49 } 50 } 51 _out.write(b); 52 } 53 54 public void close() throws IOException { 55 _out.close(); 56 } 57 58 public void flush() throws IOException { 59 _out.flush(); 60 } 61 62 } 63 | Popular Tags |