jessica_kqq
2017-11-19 11:33FileoutputStream输出问题
import java.io.*;
public class FileOutputStreamTest {
public static void main(String[] args) {
FileInputStream in = null;
FileOutputStream out = null;
int b=0;
byte[] t = new byte[6];
try {
in = new FileInputStream("D:\\asd.txt");
out = new FileOutputStream("D:\\dsa.txt");
while((b=in.read(t))!=-1) {
out.write(t,0,6);
}
in.close();
out.flush();
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.print("找不到文件");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.print("读取错误");
}
System.out.print("文件成功复制");
}
}
asd.txt中的内容为:a A 567
输出的内容为:a A 567 A 56
不懂?求解释一下。
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 字节流字符流的小问题
- java
- java-ee
- intellij-idea
- 2个回答
- js jsp 向servlet跳转过程中的request问题
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
- SSH输出SQL语句???
- struts
- spring
- hibernate
- 0个回答
- 新手学java io 输入数据和输出数据不一致?
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
- FileOutputStream的write方法
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
换一换