Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (540)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  "Universal" file loading and saving system?  (Read 1612 times)
0 Members and 1 Guest are viewing this topic.
Offline Mac70
« Posted 2012-12-26 20:07:02 »

Like in topic. Is there any way to make universal file loading and saving system that will work on any platform? I want to introduce save/load system for my game, but can't find any solution how to make it platform independent.

Check out my Devblog! Smiley
Offline cylab

JGO Ninja


Medals: 55



« Reply #1 - Posted 2012-12-26 20:20:34 »

Google ObjectOutputStream, ObjectInputStream (java standard) or YAMLBeans and XSTREAM (Kryo might be worth a look, too) for third party solutions.

If you dont have local file access, you need to write a webapp that can handle a http-post request and writes the post data to a database like mysql. You can then use a UrlConnection and one of the above classes/libs to save and load your data.

Mathias - I Know What [you] Did Last Summer!
Offline tyeeeee1
« Reply #2 - Posted 2012-12-26 20:27:23 »

Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online HeroesGraveDev

JGO Kernel


Medals: 320
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #3 - Posted 2012-12-26 20:31:53 »

Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.

Except you change the extension to keep out the n00b gremlins. Wink

Online HeroesGraveDev

JGO Kernel


Medals: 320
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #4 - Posted 2012-12-26 20:33:23 »

Like in topic. Is there any way to make universal file loading and saving system that will work on any platform? I want to introduce save/load system for my game, but can't find any solution how to make it platform independent.

Maybe you should read the Java Tutorials again.

Offline cylab

JGO Ninja


Medals: 55



« Reply #5 - Posted 2012-12-26 20:45:56 »

Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there.

Mathias - I Know What [you] Did Last Summer!
Online HeroesGraveDev

JGO Kernel


Medals: 320
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #6 - Posted 2012-12-26 20:55:16 »

Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there.

Depends where you put the game. If it is anywhere under your user folder, it will be fine. If it is in program files etc. it may fail.

Offline theagentd

« JGO Bitwise Duke »


Medals: 366
Projects: 2
Exp: 8 years



« Reply #7 - Posted 2012-12-26 21:10:12 »

Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there.
Don't do that please. I hate when games pollute my user directory. It also makes it a huge pain in the ass to change custom settings or move save files between computers. -_-' I've seen some programs feature a "portable" mode. When off it uses the user home directory for storing settings and stuff, and with it on it stores settings in the same folder, making it "portable" by allowing you to move it onto a USB stick or so.

Myomyomyo.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #8 - Posted 2012-12-26 21:23:19 »

On windows, you put things in %APPDATA%, on Linux you use $XDG_DATA_HOME, which might not even be set and defaults to $HOME/.local/share.  On OSX, no idea, and on Android there's a whole wealth of different options depending on whether it's cache, persistent, a database, etc which are explained here.

There may be portable APIs for accessing files, but you're out of luck as far as portable conventions for where to put them.
Offline Cero
« Reply #9 - Posted 2012-12-26 21:32:46 »

Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there.
Don't do that please. I hate when games pollute my user directory. It also makes it a huge pain in the ass to change custom settings or move save files between computers. -_-' I've seen some programs feature a "portable" mode. When off it uses the user home directory for storing settings and stuff, and with it on it stores settings in the same folder, making it "portable" by allowing you to move it onto a USB stick or so.

There is no choice: Since Windows Vista you cannot write savefiles or other data to C, when typically your game is installed in program files; you HAVE to use APPDATA / user.home ...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Longarmx
« Reply #10 - Posted 2012-12-26 22:21:15 »

On OSX, no idea
OSX is Library/Application Support/

Offline OttoMeier

Senior Devvie


Medals: 4
Projects: 1



« Reply #11 - Posted 2012-12-27 00:23:08 »

you could use the java Preferences API:
http://docs.oracle.com/javase/1.4.2/docs/guide/lang/preferences.html
Offline BoBear2681

JGO Coder


Medals: 19



« Reply #12 - Posted 2012-12-27 02:35:59 »

For desktop games, I'd second cylab's suggestion of looking into yamlbeans, or jsonbeans, or some other library that automatically serializes your objects into a concise, readable format (Externalizable and other XML solutions don't meet this requirement!). It'll prove invaluable when debugging. If you're concerned about the people hacking your save states (don't be), just gzip the output and give the file some extension like ".dat".
Offline ReBirth
« Reply #13 - Posted 2012-12-27 02:43:13 »

If you ask me. For desktop: same place as jar. For android: SD card.

Online HeroesGraveDev

JGO Kernel


Medals: 320
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #14 - Posted 2012-12-27 02:43:19 »

Or you could hide a md5 checksum of the save file and if it doesn't match then warn the player that their save file is corrupted.

If it is corrupted, then it won't screw up the game for them (apart from losing their data)
If it has been hacked, rhen they will most likely think they did something wrong and try again until they give up.

The again, who would bother implementing that just for this particular situation. Personally, I'd only do that if I was bored and had nothing better to do.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (20 views)
2014-12-23 03:34:11

rwatson462 (52 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (82 views)
2014-12-09 22:41:13

BurntPizza (110 views)
2014-12-08 04:46:31

JscottyBieshaar (78 views)
2014-12-05 12:39:02

SHC (89 views)
2014-12-03 16:27:13

CopyableCougar4 (93 views)
2014-11-29 21:32:03

toopeicgaming1999 (155 views)
2014-11-26 15:22:04

toopeicgaming1999 (150 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!