黑马程序员 java基础IO BufferedInputStream

来源:互联网 发布:数据泄露dlp效果 编辑:程序博客网 时间:2024/05/21 22:50


----------- android培训java培训java学习型技术博客、期待与您交流! ------------

 

 


/**

 * 演示 map3复制 通过 缓冲区
 * 
 * @author lazy
 * 
 */
public class CopyMp3Demo {


/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
copy_1();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


// 通过字节流缓冲区复制
// 缓冲区里自带数组 所以不要定义数组了
public static void copy_1() throws IOException {


//读取1.mp3字节内容
BufferedInputStream bufis = new BufferedInputStream(
new FileInputStream("1.mp3"));
BufferedOutputStream bufos = new BufferedOutputStream(
new FileOutputStream("copy1.mp3"));


int len = 0;
while ((len = bufis.read()) != -1) {
bufos.write(len);
}
bufos.close();
bufis.close();


}

}

----------------------- android培训java培训、java学习型技术博客、期待与您交流! ----------------------

详情请查看:http://edu.csdn.net/heima



0 0
原创粉丝点击