标签:style blog color os io java ar 数据 art
MP3的复制过程:
package com.lp.ecjtu; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; /** * * @author Administrator * 演示MP3的复制 * BufferedOutputStream * BufferedInputStream * */ public class CopyMp3Stream { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { long startTime = System.currentTimeMillis(); copy_1(); long endTime = System.currentTimeMillis(); System.out.println("共耗费"+(endTime-startTime)+"毫秒"); } public static void copy_1() throws IOException{ //创建一个内部缓冲数组,读硬盘中的数据到缓冲区中,字节流缓冲区 BufferedInputStream bufIos = new BufferedInputStream(new FileInputStream("D:\\1.mp3")); BufferedOutputStream buffos = new BufferedOutputStream(new FileOutputStream("2.mp3")); int by = 0; while((by=bufIos.read()) != -1){//读取缓冲区的数据到输入流中 buffos.write(by);//对输出流进行写操作 } buffos.close(); bufIos.close(); } }
java基础知识回顾之javaIO类---BufferedInputStream和BufferedOutputStream
标签:style blog color os io java ar 数据 art
原文地址:http://www.cnblogs.com/200911/p/3956169.html