二进制关键字符
DataInputStream//写入方法
DataOutputStream//写出方法
使用方法:
1先用字节流读取,明确文件地址和文件名
2然后用该字节流对象作为参数,构建二进制对象
实例:
public static void main(String[] args) {
FileInputStream fis = null;FileOutputStream fos = null;
DataInputStream dis =null;
DataOutputStream dos = null;
try {
fis = new FileInputStream("d:/jinqian.jpg");
fos = new FileOutputStream("d:/jinqian5.jpg",true);
dis = new DataInputStream( fis);
dos = new DataOutputStream( fos);
int len ;
while (( len = dis.read())!=-1) {
dos.write( len );
}
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
dos.flush();
if (dos!=null) {
dos.close();
}
if (dis!=null) {
dis.close();
}
if (fos!=null) {
fos.close();
}
if (fis!=null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}