复制文件

public class CopyMusic {
	/*
	 * 以字节为单位读取文件,常用读取二进制文件,如图片、音乐、影像等
	 */
	public static void main(String[] args) {
		byte[] tempByte = new byte[1024];
		int byteread = 0;
		try {
			FileInputStream fis = new FileInputStream("c:\\music.wma");
			FileOutputStream fos = new FileOutputStream("copy_music.wma");
			while((byteread = fis.read(tempByte)) != -1){
				fos.write(tempByte);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

 

posted @ 2012-01-02 09:14  胖鹅  阅读(136)  评论(0编辑  收藏  举报