字节流的读和写
来源:互联网 发布:sketch mac 汉化补丁 编辑:程序博客网 时间:2024/06/07 02:17
public void copy(){
InputStream in=null;
OutputStream out=null;
try {
in=new FileInputStream("D:/xx.txt");
out=new FileOutputStream("F:/xx.txt");
int len=0;
byte[] by=new byte[1024];
while((len=in.read(by))!=-1){
//写入byte数组中的数据,读取几个字节就写入几个字节
out.write(by,0,len);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
//关闭流,先建立后关闭
out.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
InputStream in=null;
OutputStream out=null;
try {
in=new FileInputStream("D:/xx.txt");
out=new FileOutputStream("F:/xx.txt");
int len=0;
byte[] by=new byte[1024];
while((len=in.read(by))!=-1){
//写入byte数组中的数据,读取几个字节就写入几个字节
out.write(by,0,len);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
//关闭流,先建立后关闭
out.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
0 0
- 字节流的读和写
- 字节流写与读
- 字节流读应对应字节流写
- JAVA读文件写文件---字节流
- 流和字节的转换
- 返回字节的写操作
- 字节写
- Java的字符流和字节流
- 字符流和字节流的区别
- 字符流和字节流的区别
- 字节流和字符流的区别
- 字节流和字符流的转换
- Java的字符流和字节流
- 字符流和字节流的选择
- 字节流和字符流的区别
- 字节流和字符流的关系
- 字节流和字符流的区别
- java的字节流和字符流
- 2.3.1笔记-线性表的链式表示和实现
- Android之进程通信机制(上)(Serializable,Parcelable,Binder)
- 斐波那契数列大数加法
- 完美配置Tomcat的HTTPS
- Android LayoutInflater inflate 理解
- 字节流的读和写
- ios基本控件之UIScrollView
- 快速合并同一个excel表中的多个sheet
- Java 信号量 Semaphore 介绍
- 关于js单线程的问题
- HDU1240 Asteroids!(BFS)
- 10、异常
- Bootstrap复习二——栅格系统(form表单示例)
- angular js过滤器