`
zhanglibin1986
  • 浏览: 374987 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

FileInputStream和FileOutputStream

    博客分类:
  • Java
阅读更多
package com.zlb.net;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class TestWriter {
	public static void main(String[] args) {
		InputStream in;
		OutputStream out;
		File f = new File("D:/c.txt");
		File f2 = new File("D:/e.txt");
		try {
			in = new FileInputStream(f);
			out = new FileOutputStream(f2);
			
//			int c;
//			while((c=in.read()) != -1) {
//				out.write(c);
//			}
			
			byte[] b = new byte[1024];
			int c;
			while((c=in.read(b)) != -1) {
				out.write(b,0,c);
			}
			in.close();
			out.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics