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

2015/4/18

Is there a possibility to have a save file in a shared Scenario

jdf1234567 jdf1234567

2015/4/18

#
Jeah almost everything is said by the header
Super_Hippo Super_Hippo

2015/4/18

#
You can use the UserInfo class to save something in an uploaded scenario. When using it, it will automatically create a '.csv' file which can save a score int, ten other ints and five strings per user.
jdf1234567 jdf1234567

2015/4/18

#
What about creating my own File in the directory the code is in?
jdf1234567 jdf1234567

2015/4/18

#
For Example a. txt File
danpost danpost

2015/4/18

#
If shared locally (within the confines of your local network), it is possible to use a '.txt' file. However, because of security issues, you will not be able to accomplish that when shared on a website (file writing restrictions).
davmac davmac

2015/4/18

#
Is there a possibility to have a save file in a shared Scenario
What do you mean by "shared Scenario"? Do you mean a scenario that you uploaded here? In that case:
What about creating my own File in the directory the code is in?
No, because the code is not in a directory; it's in a jar file hosted on a web server.
jdf1234567 jdf1234567

2015/4/18

#
what about the directory the jar File is in ?
davmac davmac

2015/4/18

#
what about the directory the jar File is in ?
You can't write to directories on this web server (it would be a huge security issue if you could). Even if you could, a "File" object in Java refers to the local file system, so you couldn't use a FileOutputStream (for example) to do so.
jdf1234567 jdf1234567

2015/4/18

#
It works on my private Server so
davmac davmac

2015/4/18

#
It works on my private Server so
Then we are talking about different things. Maybe you don't understand how scenarios run. They are implemented as Java applets and when you view them they are downloaded and run locally on your machine (with limited permissions) by the Java plugin. They do not run on the server. If they could create a file it would exist only on the users' own machine (but they can't, because applets don't have permission to write to files on the users machine).
jdf1234567 jdf1234567

2015/4/18

#
Ah ok perfect thank u much understood it. U can have a look at my Scenario so u can see what i wanted to do it for. But now you need to download it to work fine.
You need to login to post a reply.