I have written some data to a .txt file and from another Frame, I read the .txt file. Is it possible that I'm able to use the data stored in the .txt for some calculation.
Let's say the .txt only got 1 Double value. I do not want to just display it.
EDIT:
public WeightlossFat()
{
JPanel text = new JPanel();
text.add(bmi);
text.add(rbmi);
text.add(bmr);
text.add(rbmr);
text.add(tdee);
text.add(rtdee);
text.setLayout(new GridLayout(1,3));
JPanel percent = new JPanel();
percent.add(suggested);
percent.add(aggressive);
percent.add(reckless);
percent.setLayout(new GridLayout(3,1));
setLayout(new BorderLayout());
add(text,BorderLayout.NORTH);
add(percent,BorderLayout.CENTER);
suggested.addActionListener(this);
aggressive.addActionListener(this);
reckless.addActionListener(this);
try
{
BufferedReader bmi = new BufferedReader(new FileReader("bmi.txt"));
while((line = bmi.readLine()) != null)
{
currentline = line;
}
lastline = currentline;
rbmi.setText(lastline);
bmi.close();
BufferedReader bmr = new BufferedReader(new FileReader("bmr.txt"));
while((line = bmr.readLine()) != null)
{
currentline = line;
}
lastline = currentline;
rbmr.setText(lastline);
bmr.close();
BufferedReader tdee = new BufferedReader(new FileReader("tdee.txt"));
while((line = tdee.readLine()) != null)
{
currentline = line;
}
lastline = currentline;
rtdee.setText(lastline);
tdee.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "File does not exist", "Error", JOptionPane.ERROR_MESSAGE);
}
}
As you can see from the above code, I'm able to display what's inside the .txt however, I wanted to use the value in the .txt to do some calculation.
public static double suggested(double lastline)
{
//double rate = lastline * 0.15;
//double result = lastline - rate;
//return result;
}
Anybody able to teach me how to I use the value?