您的位置:首页 > 编程语言 > Java开发

JavaOOP IO 带二进制 的 读取和写入方法

2017-04-14 13:40 435 查看
/**
* @author Administrator
*
*/
public class Test7 {

/**带二进制 的 读取和写入方法
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
InputStream is=new FileInputStream("d:/花.jpg");
DataInputStream dis=new DataInputStream(is);

OutputStream os=new FileOutputStream("e:/花.jpg");
DataOutputStream dos=new DataOutputStream(os);
byte[] bytes=new byte[1024];
int data;
while ((data=dis.read(bytes))!=-1) {
dos.write(bytes, 0, data);
}
dos.close();
os.close();
dis.close();
is.close();
System.out.println("OK");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: