解决方案 »

  1.   

    在assets目录下的文件是不能这样打开的。
    在调用第三方软件打开文档的时候,你先把assets目录下的文件拷贝到sdcard的指定目录下,然后再用你上边的方法打开
      

  2.   


    /**
     * 读取资源文件
     */
    public void readAssets()
    {
    AssetManager assets = getAssets();
    try
    {
    // 获取assets资源目录下的文件 。
    InputStream stream = assets.open("ss.doc");
    if (stream == null)
    {
    return;
    }
    String folder = Environment.getExternalStorageDirectory().getPath()
    + "/mydoc/";
    File f = new File(folder);
    if (!f.exists())
    {
    f.mkdir();
    }
    String apkPath = folder + "ss.doc";
    File file = new File(apkPath);
    // 创建doc文件
    file.createNewFile();
    // 将资源中的文件重写到sdcard中
    writeStreamToFile(stream, file); } catch (IOException e)
    {
    e.printStackTrace();
    }
    } /**
     * 写文件
     * 
     * @param InputStream stream
     * @param File file
     */
    private void writeStreamToFile(InputStream stream, File file)
    {
    OutputStream output = null;
    try
    {
    output = new FileOutputStream(file);
    } catch (FileNotFoundException e1)
    {
    e1.printStackTrace();
    }
    try
    {
    try
    {
    final byte[] buffer = new byte[1024];
    int read = -1;
    while ((read = stream.read(buffer)) != -1)
    output.write(buffer, 0, read);
    output.flush();
    } finally
    {
    output.close();
    stream.close();
    }
    } catch (Exception e)
    {
    e.printStackTrace();
    } }路径也知道。