在Android Eclipse中读取文本文件失败。帮助我

时间:2015-06-02 06:03:10

标签: android eclipse android-layout

public class MainActivity extends Activity {
String data;
Writer sbuffer ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        sbuffer=null;
        try {
        InputStream is = this.getResources().openRawResource(R.drawable.config);
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        while ((data = reader.readLine()) != null)
        {
        sbuffer.append(data + "\n");
        }
        Toast.makeText(getBaseContext(), sbuffer.toString(), Toast.LENGTH_LONG).show();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}

是Android开发的新蜜蜂。我试图从drawable文件夹中读取Textfile。它显示错误请帮帮我。并且请提供代码以从可绘制文件夹

逐行读取文件

0 个答案:

没有答案