Re: [android-developers] reading a plain text file: java.lang.fileNotFoundException
Thanks, Here is how I solved it, BufferedReader reader = new BufferedReader(new InputStreamReader(ctx.getAssets().open(fileName))); Regards, John Goche On Wed, Nov 23, 2011 at 8:53 PM, Mark Murphy wrote: > You don't access assets/ by FileReader. You access assets/ via > AssetManager, which you get from a Resources object, which you > typically get via a call to getResources() on your Activity. > > On Wed, Nov 23, 2011 at 2:10 PM, John Goche > wrote: > > > > Hello, > > > > I have a really basic question. > > I am trying to read the contents of a plain text file from my > application. > > I have placed the file under MyProject/assets/foo.txt and I am trying to > > read it in my application with > > > > BufferedReader reader = new BufferedReader(new FileReader(fileName)); > > reader.read(); > > > > where fileName ="assets/foo.txt" but I get a > > java.lang.fileNotFoundException. > > > > How can I ensure that the file is found? > > > > Thanks, > > > > John Goche > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com > > For more options, visit this group at > > http://groups.google.com/group/android-developers?hl=en > > > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > Android App Developer Books: http://commonsware.com/books > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] reading a plain text file: java.lang.fileNotFoundException
You don't access assets/ by FileReader. You access assets/ via AssetManager, which you get from a Resources object, which you typically get via a call to getResources() on your Activity. On Wed, Nov 23, 2011 at 2:10 PM, John Goche wrote: > > Hello, > > I have a really basic question. > I am trying to read the contents of a plain text file from my application. > I have placed the file under MyProject/assets/foo.txt and I am trying to > read it in my application with > > BufferedReader reader = new BufferedReader(new FileReader(fileName)); > reader.read(); > > where fileName ="assets/foo.txt" but I get a > java.lang.fileNotFoundException. > > How can I ensure that the file is found? > > Thanks, > > John Goche > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] reading a plain text file: java.lang.fileNotFoundException
Hello, I have a really basic question. I am trying to read the contents of a plain text file from my application. I have placed the file under MyProject/assets/foo.txt and I am trying to read it in my application with BufferedReader reader = new BufferedReader(new FileReader(fileName)); reader.read(); where fileName ="assets/foo.txt" but I get a java.lang.fileNotFoundException. How can I ensure that the file is found? Thanks, John Goche -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en