Read byte from buffered Stream in Java

Description

The following code shows how to read byte from buffered Stream.

Example


// w ww . j a  v a  2 s  .c  om
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;

public class Main {
  public static void main(String[] args) throws Exception {

    DataInputStream in3 = new DataInputStream(new ByteArrayInputStream(
        "a dbcde".getBytes()));
    System.out.print((char) in3.readByte());
    in3.close();
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    I/O »




Binary File
Byte Array
CharSet
Checksum
Console
Create Copy Move Delete
Directory
Drive
Encode Decode
File Attribute
File Lock
File System
GZIP
Jar File
NIO Buffer
Path
Scanner
StreamTokenizer
Temporary File
Text File
Zip