Hello Community and Support!
I am not sure how to adjust "FileRead" for a conditional statement.
I would like to check if a text file has a certain certain string such as "GoLong." And take an action if that is the case.
For example:
If text in C:\temp\trading.txt = "GoLong", then buy 100,000 EUR/USD at market.
If text in C:\temp\trading.txt = "GoShort", then sell 100,000 EUR/USD at market.
I have the rest of the approach worked out. This is the only missing peice.
Below is the FileRead class from the Wiki:
public class FileRead {
public boolean read() {
boolean orderExist = false;
try {
FileInputStream fstream = new FileInputStream(FILE_NAME);
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
while (((br.readLine()) != null) ) {
orderExist = true;
return orderExist;
}
in.close();
} catch (Exception e) { // Catch exception if any
console.getOut().print("File access error: " + e.getMessage());
}
return orderExist;
}