1 18 package net.sf.drftpd.util; 19 20 import java.io.IOException ; 21 import java.io.OutputStream ; 22 23 29 public class AddAsciiOutputStream extends OutputStream { 30 private OutputStream _out; 31 private boolean _lastWasCarriageReturn = false; 32 33 37 public AddAsciiOutputStream(OutputStream os) { 38 _out = os; 39 } 40 41 47 public void write(int i) throws IOException { 48 if (i == '\r') { 49 _lastWasCarriageReturn = true; 50 } 51 if (i == '\n') { 52 if (!_lastWasCarriageReturn) { 53 _out.write('\r'); 54 } 55 } 56 _lastWasCarriageReturn = false; 57 _out.write(i); 58 } 59 60 public void close() throws IOException { 61 _out.close(); 62 } 63 64 public void flush() throws IOException { 65 _out.flush(); 66 } 67 } 68 | Popular Tags |