Jump to content

Writting Files for Script Settings


TheScrub

Recommended Posts

Hey if you use this method and release the script leave an accreditation i release these snippets for the community...

 

 

 


first we need to create a void like soo with a file name and the settings you want to it to save to an ".txt" file

    public void writeConfigSettings(String FileName,String... settings) throws IOException {

Constructing the file writer and the exact name,location of the file

        // thanks to lackofchesee from TS3 for the path name!
        FileWriter f = new FileWriter(System.getProperty("user.home")
                + File.separator + "OSBot" + File.separator + "data"
                + File.separator + FileName +".txt");
 // writing to an exact path to the osbot data folder also constructing a FileWriter

Running the settings though a for loop to get a single setting then writing it to the file and spacing it on a line below this will be needed to read the text in my reading settings file

  for (String setting : settings) { // running though the strings
            f.write(setting + System.getProperty("line.separator"));
        }

just closing the FileWriter stream of output

    f.close(); // closing the stream
    }
    public void writeConfigSettings(String FileName,String... settings) throws IOException {
        // thanks to lackofchesee from TS3 for the path name!
        FileWriter f = new FileWriter(System.getProperty("user.home")
                + File.separator + "OSBot" + File.separator + "data"
                + File.separator + FileName+".txt"); // writing to an exact path
        for (String setting : settings) { // running though the strings
            f.write(setting + System.getProperty("line.separator"));
        }
        f.close(); // closing the stream
    }

in use

String selected_herbs[] ={"Ranarr","Guam"};
writeConfigSettings("Settings",selected_herbs);

this will save a .txt file in the data folder that will look like this called "Settings"

Ranarr
Guam
Edited by TheScrub
  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...