|
Author |
Topic: saveStrings(); location (Read 1138 times) |
|
inadaze
|
saveStrings(); location
« on: Dec 5th, 2004, 4:51pm » |
|
Hi, Is there a way to tell processing where to save the .txt file to when you use the saveStrings(); function. By default it saves it in the application folder, but it would be nice if I could save it to the desktop. Thanks Jay
|
« Last Edit: Dec 5th, 2004, 4:51pm by inadaze » |
|
|
|
|
st33d
|
Re: saveStrings(); location
« Reply #1 on: Dec 8th, 2004, 1:27am » |
|
I looked at the save strings function and other save functions and wondered about this myself. I thought that surely a file name also includes the folders it's contained in. It's all part of the Uniform Resource Locator ether. Code: String words = "apple bear cat dog"; String list[] = splitStrings(words); // now write the strings to a file, each on a separate line saveStrings("C:/nouns.txt", list); |
| Behold, saved to the root drive. As for the desktop you need to get to through to the Documents and Settings folder. Past that folder you have the user that is logged on. That's going to be your biggest trouble (because if I were to run your applet on my PC you would have to guess correctly that my name is Aaron and that I've logged on as me). Far easier would be to save to root ("C:") and have done. Unless someone knows better of course, my geek skills have yet to pupate. Update Oh hang on. Just answering another query and found out how to identify the current user. Now you have to be sure they're using the right operating system. Code: String curDir = System.getProperty("user.dir"); println("\nThe current working directory is:"); println(" - " + curDir); String workDir = System.getProperty("user.home"); println("\nThe current home directory is:"); println(" - " + workDir); String nameDir = System.getProperty("user.name"); println("\nThe current user is:"); println(" - " + nameDir); |
| Update - God I'm stupid, you can identify the operating system as well. Just check this URL: http://java.sun.com/docs/books/tutorial/essential/system/properties.html
|
« Last Edit: Dec 8th, 2004, 2:12am by st33d » |
|
I could murder a pint.
|
|
|
inadaze
|
Re: saveStrings(); location
« Reply #2 on: Dec 9th, 2004, 4:49pm » |
|
I have to say that your post was probably THE most complete answer I have ever gotten. You not only answered my current question but probably future question as well.A serious thank you! Jay
|
|
|
|
|