PDA

Click to See Complete Forum and Search --> : writing , reading , bar chart.


tommie20
Apr 5th, 2010, 04:08 AM
Hi guys,

I'm trying to make a program that is capable of writing certain data ( own input ) to a "yourname" file. ( only numbers). The next step is that i have to read it again and put it in a bar chart.

I'm already stuck with the first step, anyone has some suggestions ?

Thanks,

Tom

tommie20
Apr 5th, 2010, 11:47 AM
Ok,

I now have a button that puts all the numbers that i want to add in an array.
Does anyone know how to write this array to a file?

greets,

Tom

tommie20
Apr 6th, 2010, 05:29 AM
I can write data to a file with the following code:

class KnopHandler1 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
String settoernooi = tekstvak1.getText();
String setaanmeldingen = tekstvak2.getText();
Double setDoubleaanmeldingen = new Double (setaanmeldingen);
ArrayShuttle[count] = new Badminton(setDoubleaanmeldingen, settoernooi);
count++;


JOptionPane.showMessageDialog(null, "Toernooi Toegevoegd");

}
}



Following step is to write a file of this:


class KnopHandler2 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
try
{
BufferedWriter uit = new BufferedWriter(new FileWriter(tekstvak3.getText()));

for (int i = 0; i<count;i++)
{
uit.write("" + ArrayShuttle[i].gettoernooi());
uit.newLine();
uit.write("" + ArrayShuttle[i].getaanmeldingen());
uit.newLine();

}

uit.close();

}
catch( IOException d )
{
System.out.println("Fout bij maken");
d.printStackTrace();


}
tekstvak3.setText("");

When i search the file in my workspace folder it says on line 1 : null, and on line 2 : 0,0

suggestions anyone?

Tom