Saving player data

GT6 continued…

I have the file reads working in a jar with an InputStreamReader(Class.class.getResaourceAsStream(filename))

now how do I turn around and write to that file using the Class and the reference point for file lcoation?

Have tried BufferedWriter to the file, but it requires a full path(c:…) instead of knowing where I am at in the folder tree based on the class calling the save method.

M

To my knowledge, you can’t. When you use getResourceAsStream, it’s going to find the data somewhere in the classpath (including JARs), and to my knowledge, there is no way to get the ‘physical’ location of the resource that you accessed, and I don’t even know how you would represent that if the resource came from a JAR.

IIRC, there is a preferences API you can use to store the save folder and file name and maybe you could use that?

-Chris

Is this really about networking or would it be better moved to a different topic? (I have almost no idea what you’re talking about :))

actually I was pretty straight forward. Can I save to a text file from a class without having to use the entire path for the file(c:\asdsad\asdsafd\filename.ext)

You can do it to read a file(Class.class.getResourceAsStream(filename)) and this knows you are coming from the location of the class file. As for topic location…I didnt see another topic that fit. sorry

getResource() returns a URL that describes the palce getResourceAsStream() would get the resource from.

I seem to remember James Gosling’s new Juicy News Network program writes data to the Application Data directory. It runs using WebStart. Hope this helps?