G
Geoff Cox
Hello,
I'm not clear how to write a vlaue to a file on the hard disk ... I
have the code below and wish to write the getValue() number to disk.
I am guessing that I need to call (with this value) a method to do
this but my following effort is wrong. Please see also the rest of the
code after my signature
writeToFile(scale.getValue());
}
public static String writeToFile (int num)
{
try
{
FileWriter file = new FileWriter("data.txt");
BufferedWriter buffer = new BufferedWriter(file);
buffer.write(num);
buffer.close();
}
catch(IOException e) { System.out.println(e); }
}
Help! please
Geoff
--------------------
public void stateChanged(ChangeEvent event)
{
JSlider src = (JSlider) event.getSource();
if(!src.getValueIsAdjusting())
position.setText("Position is
"+scale.getValue());
writeToFile(scale.getValue());
}
public static String writeToFile (int num)
{
try
{
FileWriter file = new FileWriter("data.txt");
BufferedWriter buffer = new BufferedWriter(file);
buffer.write(num);
buffer.close();
}
catch(IOException e) { System.out.println(e); }
}
I'm not clear how to write a vlaue to a file on the hard disk ... I
have the code below and wish to write the getValue() number to disk.
I am guessing that I need to call (with this value) a method to do
this but my following effort is wrong. Please see also the rest of the
code after my signature
writeToFile(scale.getValue());
}
public static String writeToFile (int num)
{
try
{
FileWriter file = new FileWriter("data.txt");
BufferedWriter buffer = new BufferedWriter(file);
buffer.write(num);
buffer.close();
}
catch(IOException e) { System.out.println(e); }
}
Help! please
Geoff
--------------------
public void stateChanged(ChangeEvent event)
{
JSlider src = (JSlider) event.getSource();
if(!src.getValueIsAdjusting())
position.setText("Position is
"+scale.getValue());
writeToFile(scale.getValue());
}
public static String writeToFile (int num)
{
try
{
FileWriter file = new FileWriter("data.txt");
BufferedWriter buffer = new BufferedWriter(file);
buffer.write(num);
buffer.close();
}
catch(IOException e) { System.out.println(e); }
}