This site requires JavaScript, please enable it in your browser!
Greenfoot back
stevenGrohe
stevenGrohe wrote ...

2012/2/14

using text files in a game

1
2
Duta Duta

2012/2/16

#
I'm not sure what the issue with your code is, however first off, here's my method for getting the BufferedReader when I want to do this:
String fileName = "ATextFile.txt";
BufferedReader br = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(fileName)));
And also, I find it easier to simply have the method throw any exceptions, and then when you're calling the method enclose it in a try/catch - it makes no difference, I just prefer how it looks.
davmac davmac

2012/2/17

#
if this won´t work , please tell me why, and how it WILL work , when I load it up to the gallery
That will work when running from within Greenfoot, but not on the gallery - as you've used FileInputStream. You should use the technique outlined by Builderboy2005 and Duta (above). If you did use that technique, it would work both on the gallery, and when running from within Greenfoot.
stevenGrohe stevenGrohe

2012/2/17

#
okay thanks
You need to login to post a reply.
1
2