今天写一个例子程序,就是把android文件夹res下面的图片拷贝到sd卡里面,但是到:
  FileOutputStream fos = new FileOutputStream(photoFile);的时候就报FileNotFoundException异常。package com.test.aiai;import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;public class UpActivity extends Activity {
    private String TAG="fileuploaddownload" ;
    public static String cloudUrl ;
    public static String cloudUrl_path="";
    public static final String PATH="/sdcard/fileio/";
    public final String SD_PATH=android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
    //通过测试SD_PATH为:/mnt/sdcard
public static final String FILE_PATH ="/fileio";
private final String NATIVE_FILENAME ="sa_native.png";
private final String NETWORD_FILENAME="sa_network.jpg";
private ImageView img1 ,img2 ;
private Button mbt1 ;
private OnClickListener up_listener = null ;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);;
        this.img1=(ImageView)findViewById(R.id.img1) ;
        this.mbt1=(Button)findViewById(R.id.but);
        try
        {//把文件夹下面的图片转换成流的形式
         InputStream in =getResources().openRawResource(R.drawable.ic_launcher);
         //从流中读取图片成为Bitmap格式
         Bitmap bm = BitmapFactory.decodeStream(in);
         in.close();
         //设置图片显示,从Bitmap中读取
         img1.setImageBitmap(bm);
        }
        catch(IOException e)
        {
         e.printStackTrace();
        }  
      String photoFilename = SD_PATH+FILE_PATH+"/"+NATIVE_FILENAME ;  
      File photoFile =new File(photoFilename);   //指明需要的文件夹的全路径  
      try
      {
Toast.makeText(this, "3", Toast.LENGTH_LONG).show();
       InputStream in = getResources().openRawResource(R.drawable.ic_launcher);
       Toast.makeText(this, "4", Toast.LENGTH_LONG).show();
       FileOutputStream fos = new FileOutputStream(photoFile);
      
       byte[] buffer = new byte[8192];
       int count = 0 ;
       while((count=in.read(buffer))>0)
       {
       fos.write(buffer,0,count);
       }
       fos.close();
       in.close();
       Toast.makeText(this, "chenggon", Toast.LENGTH_LONG).show();
      }
      catch(FileNotFoundException e)
      {
       Toast.makeText(this, "文件没有找到异常", Toast.LENGTH_LONG).show();
       e.printStackTrace();
      }catch(IOException e)
      {
       e.printStackTrace();
       Toast.makeText(this, "io", Toast.LENGTH_LONG).show();
      }catch(Exception e)
      {
       Toast.makeText(this, "cuowu", Toast.LENGTH_LONG).show(); 
      }
      
        
    }
}运行结果:可以输出3数字,但是之后直接输出“文件没有找到异常”,为什么?????