io流
来源:互联网 发布:人民银行金融数据 编辑:程序博客网 时间:2024/06/06 20:18
package com.java1;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.junit.Test;
public class TestFile {
@Test
public void test1(){
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = newFileInputStream("hello.txt");
fos = newFileOutputStream("hello2.txt",true);
核心代码注意FileOutputStream后面的true的意思是继续接着源文件读入进去也会换行
byte[] b =newbyte[2];
int len;
while((len =fis.read(b)) != -1){
fos.write(b,0,len);
}
} catch (IOException e) {
e.printStackTrace();
}finally{
if(fos !=null){
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(fis !=null){
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
- 【IO流】IO框架
- IO流呀IO流
- 字符IO&数据流IO&对象流IO
- io流
- io流
- IO流
- IO流
- IO 流
- IO流
- io流
- IO流
- io流
- IO流
- IO流
- IO流
- IO流
- IO流
- IO流
- 20170519@静态导入
- 关于TabLayout与Viewpager绑定后TAB上的文字不显示问题
- TCP(Transmission Control Protocol) 传输控制协议
- 短信验证(mob)
- Linux下目录的简单说明
- io流
- Robotframework环境搭建
- HTMl5的存储方式sessionStorage和localStorage详解
- mysql 安装
- Android画图相关。取高度宽度,画矩形。
- c++ map数据结构比较同义词去重,转换排除
- S5PV210系列 (裸机十)之按键和CPU的中断系统(一)
- Kotlin-------------Android 开发一级语言
- Gym