1 22 23 package gnu.mail.util; 24 25 import java.io.BufferedInputStream ; 26 import java.io.FilterInputStream ; 27 import java.io.InputStream ; 28 import java.io.IOException ; 29 30 import javax.mail.Session ; 31 41 public class CRLFInputStream 42 extends ReadFilterInputStream 43 { 44 47 public CRLFInputStream (InputStream in) 48 { 49 super (in.markSupported () ? in : new BufferedInputStream (in)); 51 } 52 53 58 public int read () 59 throws IOException 60 { 61 final int CR = 13; 63 final int LF = 10; 64 65 final int MarkReadLimit = 5; 67 68 int c = super.read(); 69 if (c == CR) { 70 71 mark (MarkReadLimit); 73 c = super.read (); 74 if (c != LF) { 75 76 reset (); 78 c = CR; 79 80 } 81 82 } 83 84 return c; 85 } 86 } 87 | Popular Tags |