I'm trying to save numbers based off of letters. For example, A would store 2, B would store 4, C would store -3, etc. However, it appears that it can only save one variable at a time. I posted the writing section of the code.
The File declaration is not listed here but is first declared null and then initialized on the constructor.
By my guess, it's the section:
Even though it writes to a specific letter, it tends to always to overwrite the letter and that function and puts in its own number. How do I regulate each section without overriding the letter that already has a number in it? If you didn't understand, I'll explain it. Let's say you wanted to save a number to variable A. When you click on it, it would look like this on the document:
A=4
and you wanted to save another number to variable B. When you click on it, it'll override A and it would look like this:
B=3
When I launch the application, it'll show me this:
B=3
But Variable A is gone.
Code:
void writeDataVariable(double number, int letter) //For Variable writing purposes
{
try
{
System.out.println("Writing Data");
FileOutputStream outputStream = new FileOutputStream(data);
//Writes to the Variable
write(outputStream, Character.toString((char)(65+letter)) + "=" + Double.toString(number));
System.out.println("Done! Writing successful to Variable " + Character.toString((char)(65+letter)));
} catch (IOException ioe)
{
System.out.println("Error: " + ioe.getMessage());
}
}
void write(FileOutputStream stream, String output)
throws IOException {
output = output + "\n";
byte[] data = output.getBytes();
stream.write(data, 0, data.length);
}
By my guess, it's the section:
Code:
write(outputStream, Character.toString((char)(65+letter)) + "=" + Double.toString(number));
A=4
and you wanted to save another number to variable B. When you click on it, it'll override A and it would look like this:
B=3
When I launch the application, it'll show me this:
B=3
But Variable A is gone.