New File Type

Discussion in 'Mac Programming' started by eatpie26, Jan 14, 2011.

  1. eatpie26, Jan 14, 2011
    Last edited: Jan 14, 2011

    eatpie26 macrumors newbie

    Joined:
    Jan 4, 2011
    #1
    I'm sorry if this is in the wrong section, but I didn't know where else to put it. I am making a game with Java, and I want the user to be able to save they're progress on their computer. In order to do this, I want to create a new type of file to save it as such as .doc or .ppt. I apologize if this is a stupid question, but how do I make a new file type to save the game data? I am using Mac OSX 10.7.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
  3. eatpie26 thread starter macrumors newbie

    Joined:
    Jan 4, 2011
    #3
    I'm not making a Java app. It's just a program written in Java. I know it's possible to make a new file type, but I'm not sure how. If anyone knows, please tell me.
     
  4. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #4
  5. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    That won't be possible if the Java program is a jar-file, or loose class files.
     
  7. eatpie26, Jan 14, 2011
    Last edited: Jan 14, 2011

    eatpie26 thread starter macrumors newbie

    Joined:
    Jan 4, 2011
    #7
    I am making the file as a jar-file. Which method should I use for that?
     
  8. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #8
    The save file will still be in an external directory somewhere. As far as the format of the file, most people would just open up a file descriptor and come up with a custom format.
     
  9. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #9
    1. I bet you are _not_ using Mac OSX 10.7.

    2. The easiest way to do this without causing any problems to anyone, and at the same time the correct way, is to create a folder for your application inside the "Application Support" folder. There is no reason whatsoever to give this file any particular file type. Just write a plist, or an xml file, or a plain text file, whatever you prefer.
     
  10. eatpie26 thread starter macrumors newbie

    Joined:
    Jan 4, 2011
    #10
    Sorry. That was a typo. Also, where is the application support folder?
     
  11. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #11
    Ahem...

    It is called "Application Support". It is in the user's home directory, in the "Library" folder. Have a look at what folders you find in your "Library" folder; for example, there is a folder where you should put your Preferences file. There are methods in Cocoa that give you the proper path, but if there is nothing in Java, then you should just access "Library/Applications Support" in the user's home directory.
     
  12. eatpie26 thread starter macrumors newbie

    Joined:
    Jan 4, 2011

Share This Page