I have a java assignment, and my last two errors are laid out in this code. For a little background, my code is taking input from a GUI and writing it into a text file. I realize you may need more code, and I will give more if needed, I just can't seem to understand these errors. Here is my code:
public void dataWriter(String data, String fileName) throws IOException
{
File file = getFileStreamPath(fileName);
if (!file.exists())
{
file.createNewFile();
}
try (FileOutputStream writer = openFileOutput(file.getName(), Context.MODE_PRIVATE)) // Error "cannot find symbol, variable MODE_PRIVATE"
{
for (String string = null, data)//error "variable data is already defined in dataWriter"
{
{
writer.write(string.getBytes());
writer.flush();
}
}
}
catch (Exception e)
{
}
}
Any help is greatly appreciated. Thank you so much!