文件读字节
来源:互联网 发布:c语言 if break 编辑:程序博客网 时间:2024/06/10 14:46
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) {
}
}
}
}