一、当ins.available()值是53980299时也就是文件大于50M时, java.lang.reflect.InvocationTargetException
byte[] 字符数组
InputStream ins = new BufferedInputStream(new FileInputStream(file));
ByteBuffer buffer=ByteBuffer.allocate(ins.available());//当ins.available()值是53980299时也就是文件大于50M时
ins.read(buffer); //这个地方直接读取的, 让一下带颜色的进行分开读取实现
ins.close();
当ins.available()值是53980299时也就是文件大于50M时出现 java.lang.reflect.InvocationTargetException,把以上语句更改成以下即可:
FileOutputStream out=new FileOutputStream(file);
int c;
byte[] buffer = new byte[1024];
while((c=ins.read(buffer))!=-1){
for(int i=0;i<c;i++){
out.write(buffer[i]);
}
}
buffer = new byte[ins.available()];
//ByteBuffer buffer=ByteBuffer.allocate(ins.available());
/// ins.read(buffer);
ins.close();
out.close();//Add By WGY 20140715