android java eclipse getFileFromSdcard为什么获取不到内容,我文件里面有内容

//获取内容的代码
public void readFile(){
Context context = getContext();
FlieService fileService = new FlieService(context);
String msgString = fileService.getFileFromSdcard("text.txt");//获取文件内容
Log.i(TAG, "-->>" + msgString);
}
//这个是getFileFromSdcard获取的方法
public String getFileFromSdcard(String filename){
FileInputStream inputStream = null;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();//缓冲区缓存的流,与磁盘无关,不需要关闭
File file = new File(Environment.getExternalStorageDirectory(),filename);
if(Environment.MEDIA_MOUNTED.equals(
Environment.getExternalStorageDirectory())){
try {
inputStream = new FileInputStream(file);
int len = 0;
byte[] data = new byte[1024];//字节缓冲数组
try {
while((len = inputStream.read(data))!=-1){
outputStream.write(data,0,len);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(inputStream!=null){
try {
inputStream.close();//关闭
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

第1个回答  2013-04-10
ENCTYPE =“多重/表单数据”> 惹的祸追问

那要怎么解决呢?

相似回答
大家正在搜