new ByteArrayInputStream(byte[] buf)
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
try {
DataInputStream in3 = new DataInputStream(
new ByteArrayInputStream("a dbcde".getBytes()));
while(true)
System.out.print((char)in3.readByte());
} catch(EOFException e) {
System.err.println("End of stream");
}
}
}
Related examples in the same category