1 17 package org.apache.commons.collections.primitives.adapters.io; 18 19 import java.io.InputStream ; 20 21 import org.apache.commons.collections.primitives.ByteIterator; 22 23 29 public class ByteIteratorInputStream extends InputStream { 30 31 public ByteIteratorInputStream(ByteIterator in) { 32 this.iterator= in; 33 } 34 35 public int read() { 36 if(iterator.hasNext()) { 37 return (0xFF & iterator.next()); 38 } else { 39 return -1; 40 } 41 } 42 43 public static InputStream adapt(ByteIterator in) { 44 return null == in ? null : new ByteIteratorInputStream(in); 45 } 46 47 private ByteIterator iterator = null; 48 49 } 50 | Popular Tags |