Android 如何读取.doc文件?

Android 如何读取.doc文件?,android,Android,我有一个.doc文件保存在我的SD卡上。我需要阅读.doc文件的内容,并在文本视图中显示它 谁能告诉我怎么做吗?对不起,我弄错了。你需要这样做 public void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.main); String extPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File

我有一个
.doc
文件保存在我的SD卡上。我需要阅读
.doc
文件的内容,并在
文本视图中显示它


谁能告诉我怎么做吗?

对不起,我弄错了。你需要这样做

public void onCreate(Bundle b) {
    super.onCreate(b);
    setContentView(R.layout.main);
    String extPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.Separator;
    InputStream inputStream = assetManager.open(extPath + "file.doc");
    String text = loadFile(inputStream);
    TextView tv = (TextView) findViewById(R.id.txtv);
    tv.setText(text);
}

public String loadFile(InputStream inputStream) {
    ByteArrayOutputStream b = new ByteArrayOutputStream();
    byte[] bytes = new byte[4096];
    int length = 0;
    while () {
        b.write(bytes, 0, length);
    }
    return new String(b.toByteArray(), "UTF8");
}

AssetManager用于访问apk中的资源,而不是访问SD卡上的数据。问题似乎更多的是从.doc文件中提取纯文本并在文本视图中显示,可能带有一些基本格式。@hossaindoula I似乎while循环有问题。你在里面放了什么?你的代码有错误,首先你没有使用inputStream,其次你的while循环缺少参数