读取失败:EBADF(错误的文件数) [英] read failed: EBADF (Bad file number)
本文介绍了读取失败:EBADF(错误的文件数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试这样做外部存储的拷贝一个文件到文件夹中的数据库,这个错误发生:
When I try do a copy one file of the external storage for into folder database, this error happens:
java.io.IOException异常:读取失败:EBADF(错误的文件数)
java.io.IOException: read failed: EBADF (Bad file number)
此错误上,而这种方法的线路发生
This error happens on the line of while of this method
private void copiarBaseDados(InputStream input) throws IOException{
OutputStream output = new FileOutputStream(ConfiguracoesBaseDados.BANCO_PATH + ConfiguracoesBaseDados.BANCO_NOME);
int tamanho;
byte[] buffer = new byte[1024];
while ((tamanho = input.read(buffer)) > 0)
output.write(buffer, 0, tamanho);
output.flush();
output.close();
input.close();
}
任何想法可能是什么问题?谢谢
Any idea what could be the problem? Thanks
推荐答案
请阅读之前,你的输入(流)是否存在。
Check whether your input(stream) exists before reading.
也看到,如果你有这些PERMISSONS:
Also see if you have these permissons:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
这篇关于读取失败:EBADF(错误的文件数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文