您的位置:首页 > 其它

字节输入输出流

2017-02-08 13:51 288 查看
import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

public class InputOutput {
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;

try {
fis = new FileInputStream("D:\\liangsong\\hello.txt");
fos = new FileOutputStream("D:/a.txt");

byte[] b = new byte[1024];
int len;
while( (len = fis.read(b) ) != -1){
fos.write(b,0,len);
}
fos.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fos.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

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