Read one byte from a file
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { public void readOneByte() throws FileNotFoundException { FileInputStream file = null; byte x = -1; try { file = new FileInputStream("fileName"); x = (byte) file.read(); } catch (FileNotFoundException f) { throw f; } catch (IOException i) { i.printStackTrace(); } finally { try { if (file != null) { file.close(); } } catch (IOException e) { } } } }