字节输入输出流
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();
}
}
}
}
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();
}
}
}
}
相关文章推荐
- Java文件字节输入流(FileInputSream)文件字节输出流(OutputStream),字符输入输出流(FileReader/FileWriter)
- IO流输入输出流,字符字节流
- Java中面向字节的输入输出流
- [02] 输入/输出流 和 字节/字符流
- 字节输入输出流
- FileOutputStream字节输出流和FileInputStream输入流(切记:out是输出到本地中,in是输入到程序中)这里介绍大文件和小文件的读取方式
- Java中的字节输入出流和字符输入输出流
- 学习笔记_JavaSE_20_字节输入输出流、字节缓冲流
- java中字节输入输出流操作详解
- 唠唠SE的IO-02——字节输入输出流
- 字节输入输出流
- 字节 输入输出流 byte
- 【慕课笔记】4-4 字节流之数据输入输出流
- Java基础-IO-字节输入输出流(笔记)
- 字节输入输出流的代码注意事项
- JavaIO 总结笔记<三> 基本字节字符输入输出流和文件复制
- IO(1) 文件字节输入输出流
- Java 7源码分析第13篇 - 字节输入输出流(1)
- java输入输出流、字符字节流
- java入门教程-8.4Java中面向字节的输入输出流