拷贝mp3java_字节流复制mp3文件(带缓冲区)
生活随笔
收集整理的這篇文章主要介紹了
拷贝mp3java_字节流复制mp3文件(带缓冲区)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//自定義的緩沖區
import java.io.*;
class? MyBufferedInputStream
{
private byte[] buf = new byte[1024];
private InputStream in;
private int pos = 0, count = 0;
MyBufferedInputStream(InputStream in){
this.in = in;
}
/*
一次讀一個字節,從緩沖區字節數組中讀。
*/
public int myRead(){
//通過in對象讀取硬盤數據,并存儲buf中
if(count == 0){
count = in.read(buf);
if(count < 0)
return -1;
pos = 0;
byte b = buf[pos];
count--;
pos++;
return b;
}else if(count > 0){
byte b = buf[pos];
count--;
pos++;
return b;
}
return -1;
}
public void myClose(){
in.close();
}
}
總結
以上是生活随笔為你收集整理的拷贝mp3java_字节流复制mp3文件(带缓冲区)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 容易答错的java面试题_Java程序员
- 下一篇: postman安装报错 无法定位_VS2