Edit: I have figured out a solution to this problem and it is very similar to was MS90 commented. Since my working directory is "ATM project", then java will only be able to notice relative path's I give it within that directory. Changing my path name to "group_0331\phase1\deposits.txt" did the trick as "group_0331" is in my current directory. The file is now created where I want it, under phase1.
I need to be able to write this file (and read from) to the same directory as the java file that has the createAccount method. So not the working directory. Also, I can't hard code the path name because this file will not always be run from the same computer. How can I do this?
void createAccount(String name, String accountType){
try {
accounts = new File("accounts.txt");
Writer writer = new BufferedWriter(new FileWriter(accounts, true));
writer.write(String.format("%s \naccounts: %s", name, accounts));
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}