JAVA在IO下使用InputStream和OutputStream实现文件的复制

日常更一下java学习中遇到的问题

package baoxinhai_test;
import java.io.*;
public class file_copy {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			InputStream input = new FileInputStream("F://java_test//input.txt");
			OutputStream output = new FileOutputStream("F://java_test//output.txt");
			byte[] bs=new byte[512];
			int tem=input.read(bs);
			while(tem!=-1)
			{
				output.write(bs);
				tem=input.read(bs);
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		} finally {
			//output.close();
			System.out.println("Everything is done!");
		}
	}

}

你可能感兴趣的:(JAVA后端开发)