FileInputStream fis = new FileInputStream(file);
//fos.write("this is a test!".getBytes());
System.out.println("input is ok");
fis.close();

FileOutputStream fos = new FileOutputStream(file);
System.out.println("output is ok");
fos.close();
====
就这么一点代码,file已经创建好了
fis完没有问题,fos初始化时就报FileNotFoundException...
权限是添加过的,求解

解决方案 »

  1.   

    fis.close();这里,还要继续操作呢,要不哪来输出流。
      

  2.   

    不应该吧,你确认文件已经创建了么?可以通过ddms或者adb shell ->ls查看是否已经存在。
      

  3.   

    是不是你程序中的file路径写错了?
      

  4.   

    已经通过adb shell检查过了,确实存在
      

  5.   

    fis没有报异常路径错了的话,两个都要报异常
      

  6.   

    用isWritable测了下,是可以读的
      

  7.   

         String filePath = Environment.getExternalStorageDirectory() + "/data.txt";
         File file = new File(filePath);
         if(!file.exists()){
         try {
    file.createNewFile();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
         System.out.println("data.txt has created");
         }else{
         System.out.println("data.txt exists");
         }
    应该不是路径问题