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

2012/5/4

Can't seem to upload game properly :(

Omniscience Omniscience

2012/5/4

#
When I upload the game I've been working on, all I get is a blank screen. See my scenario: Jump-Start Game. I literally just uploaded it.
mjrb4 mjrb4

2012/5/4

#
This is what the Java console is for ;) When starting your game:
java.security.AccessControlException: access denied (java.io.FilePermission Questions Log.csv read)
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkRead(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileReader.<init>(Unknown Source)
	at QuestionWriter.<init>(QuestionWriter.java:32)
	at Level.prepare(Level.java:123)
	at Level.<init>(Level.java:95)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at greenfoot.export.GreenfootScenarioViewer.instantiateNewWorld(GreenfootScenarioViewer.java:310)
	at greenfoot.export.GreenfootScenarioViewer.init(GreenfootScenarioViewer.java:215)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Basically, it looks like you're trying to read from a file on the filesystem, Log.csv, which for obvious reasons isn't allowed in an applet.
Omniscience Omniscience

2012/5/4

#
So, I should type this into the prepare statement of my world class? EDIT: Ok, stupid question- that's the error message. What I would like to know is how can I make java accept that I have a csv file in it?
Omniscience Omniscience

2012/5/4

#
Help!
davmac davmac

2012/5/4

#
This has come up before. Briefly:
import java.net.URL;

...

URL resourceURL = getClass().getClassLoader().getResource(fileName);
InputStream input = resourceURL.openStream();
You can't write to the file, only read it.
Omniscience Omniscience

2012/5/4

#
Okay. And whereabouts would I store this? In the prepare statement of myWorld I imagine?
davmac davmac

2012/5/4

#
The import statement goes at the top of your source file. You need to import java.io.InputStream as well (I forgot to put it in). The other two lines go wherever you want to actually read the contents of the file. You use the InputStream for reading. You might want to wrap it with an InputStreamReader.
Omniscience Omniscience

2012/5/4

#
I am currently using BufferedReader to read in files... so would I have to swap that out for InputStream?
davmac davmac

2012/5/4

#
There's no reason why you couldn't continue to use a BufferedReader. Like I said before, you might want to wrap the InputStream with an InputStreamReader, and you can wrap that with a BufferedReader.
You need to login to post a reply.