public?static?void?printBBB(File?myFile)?throws?IOException{
FileInputStream?myFileInputStream?=?new?FileInputStream(myFile);
//添加部分
FileOutputStream?myOutputStream?=?new?FileOutputStream("e:\\b.mp3");
byte[]?myByte?=?new?byte[1024*1024];
int?j=0;
int?len=0;
System.out.println(myFile.length());
long?startTime=System.currentTimeMillis();
while(?(len?=?myFileInputStream.read(myByte,?0,?myByte.length))!=-1){
for?(int?i?=?0;?i?<?len;?i++)?{
if(j++%73?==?0){
System.out.println("\r\n"+"10個數(shù)據(jù)");
}
System.out.print(Integer.toHexString(myByte[i]&0xff)+"?");
/***********************************
添加一下代碼后打印輸出的數(shù)據(jù)亂碼,第一行數(shù)據(jù),正常,然后一大片?00?,后面又是亂碼
************************************/
myOutputStream.write(myByte,0,len);
myOutputStream.flush();
}
long?endTime=System.currentTimeMillis();
System.out.println("\r\n"+"讀取文件所用時間:"+((endTime?-?startTime)/1000));
}
myFileInputStream.close();
myOutputStream.close();
}
2015-12-15
看看你的項目默認(rèn)的字符編碼和你的字符編碼是否一致 ?不一致就會出現(xiàn)亂碼問題