JAVA中怎样操作Bianry二进制文件?

来源:百度知道 编辑:UC知道 时间:2024/05/21 04:21:35
例如,我需要获取里面的的有用信息【如用户名,序列号等等】
可以吗?

可以的,用InputStream就可以了
BufferedInputStream in = new BufferedInputStream(new FileInputStream("d:/a.doc"));
byte[] b = new byte[1024];
while(true){
int length = in.read(b );
if(length<0){
break;
}
//处理b的内容
}
in.close();

以字节读取 用 FileInputStream

以字符读取,在上面基础上 加 Reader封装