Source Code : Reading Bytes from a DataInputStream
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Reading Bytes from a DataInputStream

import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class EOF {
public static void main(String args[]) {
DataInputStream is = null;
byte ch;
try {
is = new DataInputStream(new FileInputStream("EOF.java"));
while (true) { // exception deals catches EOF
ch = is.readByte();
System.out.print((char) ch);
System.out.flush();
}
} catch (EOFException eof) {
System.out.println(" >> Normal program termination.");
} catch (FileNotFoundException noFile) {
System.err.println("File not found! " + noFile);
} catch (IOException io) {
System.err.println("I/O error occurred: " + io);
} catch (Throwable anything) {
System.err.println("Abnormal exception caught !: " + anything);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ignored) {
}
}
}
}
}
Thank with us