KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > util > DecodingStream


1 package hudson.util;
2
3 import java.io.FilterOutputStream JavaDoc;
4 import java.io.IOException JavaDoc;
5 import java.io.OutputStream JavaDoc;
6
7 /**
8  * Hex-binary decoding stream.
9  *
10  * @author Kohsuke Kawaguchi
11  * @see EncodingStream
12  */

13 public class DecodingStream extends FilterOutputStream JavaDoc {
14     private int last = -1;
15
16     public DecodingStream(OutputStream JavaDoc out) {
17         super(out);
18     }
19
20     public void write(int b) throws IOException JavaDoc {
21         if(last==-1) {
22             last = b;
23             return;
24         }
25
26         out.write( Character.getNumericValue(last)*16 + Character.getNumericValue(b) );
27         last = -1;
28     }
29
30
31 }
32
Popular Tags