List of usage examples for java.io ByteArrayInputStream ByteArrayInputStream
public ByteArrayInputStream(byte buf[])
From source file:Main.java
public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try {/*from w w w. j a v a2 s . co m*/ for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } pis.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try {//from w ww.ja va2 s . co m for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } pis.reset(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is, 10); try {//w ww . ja va 2 s .com for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } byte[] b = { 'W', 'o', 'r', 'l', 'd' }; pis.unread(b); for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try {//w ww. j a va 2 s . co m for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try {/*from www. j a v a2s . co m*/ for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } pis.mark(5); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try {//from w ww .ja v a 2 s. c om pis.skip(1); for (int i = 0; i < byteArray.length - 1; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is, 10); try {//from w w w . ja v a 2 s . c o m for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } byte[] b = { 'W', 'o', 'r', 'l', 'd' }; pis.unread(b, 2, 3); for (int i = 0; i < 3; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws IOException { byte[] buf = { 65, 66, 67, 68, 69 }; // create new byte array input stream ByteArrayInputStream bais = new ByteArrayInputStream(buf); }
From source file:ByteArrayInputStreamDemo.java
public static void main(String args[]) throws IOException { String tmp = "abcdefghijklmnopqrstuvwxyz"; byte b[] = tmp.getBytes(); ByteArrayInputStream input1 = new ByteArrayInputStream(b); ByteArrayInputStream input2 = new ByteArrayInputStream(b, 0, 3); }
From source file:Main.java
public static void main(String[] args) throws IOException { byte[] buf = { 1, 2, 3, 4, 5 }; InputStream is = new ByteArrayInputStream(buf); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { byte b = dis.readByte(); System.out.print(b);/*from w ww .j a v a 2 s . c o m*/ } }