楼主,注意文件的写入编码方式和读取编码方式要一致啊!推荐用utf-8编码,写入用这个编码,读取也用这个。

解决方案 »

  1.   

    你好,我初学android,读取文件是直接从txt文件中读取的     try {
    InputStream in = getResources().getAssets().open("data.txt");
    BufferedReader buffer = new BufferedReader(new InputStreamReader(in, "utf-8"));

    String pureWord = new String();
    String explain = new String();

    while((pureWord = buffer.readLine()) != null){
    explain = buffer.readLine();
    words.add(new Word(pureWord, explain));
    }
    in.close();
    } catch (IOException e) {
    e.printStackTrace();

    这样还是出错了,为什么啊?
      

  2.   


    你确信data.txt是utf-8编码吗? 用notepad++创建一个包含中文的utf-8编码的文件,再打开试试?
      

  3.   


    你要确定你的data.txt文件是用utf-8编码写入的?你把这个文件拉出来,用notepad++打开,utf-8编码方式看看是不是乱码。  
    或者你按楼上说的新创建一个utf-8编码的文件,随便写点内容进去,然后代码读取出来看看。