Reading & writing an external text file?
Reading & writing an external text file?
I've noticed a board method that let you see the directory the bot is in, and there are a lot of "storage" methods, but I'm not sure how they're supposed to be used.
Code: Select all
import java.io.*;
...
void writeFile() {
FileWriter writer = new FileWriter(board.getAgentPath() + File.separator + fileName);
writer.write(stuff);
writer.flush();
writer.close();
}
...
void readFile() {
BufferedReader reader = new BufferedReader(new FileReader(board.getAgentPath() + File.separator + fileName));
String line;
while((line = reader.readLine()) != null) {
//do something with line
}
reader.close();
}
To use the Lux API storage functions, your code will look like this:
Code: Select all
void storeHitList() {
board.storagePut("hitList", "Cluster, Yakool, EvilPixie, dustin");
}
void retrieveHitList() {
hitList = board.storageGet("hitList", "the hitlist is empty"); //this last is the default value if Lux can't find any data called "hitList"
}
Who is online
Users browsing this forum: No registered users and 59 guests