主题:java写批量byte[]到文件里
我在向文件里写byte数组时,如下:
public void writeToBytes(byte bytes[],String fileName){
FileOutputStream fos=null;
try{
fos=new FileOutputStream(fileName,true);
fos.write(bytes);
fos.flush();
}
catch(Exception e){
e.printStackTrace();
Logger.getInstance().logPrint("writeObject", "写byte数组出错:"+e.getMessage());
}
finally{
try{
fos.close();
}
catch(IOException iex){}
}
}
//*****************************
觉得这样实现效率很低,我想批量写,每隔一段时间,就写一个byte[]块,不知道怎么实现,不知道是否有朋友实现过。
public void writeToBytes(byte bytes[],String fileName){
FileOutputStream fos=null;
try{
fos=new FileOutputStream(fileName,true);
fos.write(bytes);
fos.flush();
}
catch(Exception e){
e.printStackTrace();
Logger.getInstance().logPrint("writeObject", "写byte数组出错:"+e.getMessage());
}
finally{
try{
fos.close();
}
catch(IOException iex){}
}
}
//*****************************
觉得这样实现效率很低,我想批量写,每隔一段时间,就写一个byte[]块,不知道怎么实现,不知道是否有朋友实现过。