Problem with this. Help!
Hey guys, this is very important...
Any ANY help will be much appreciated
READ THE COMMENTS FOR DESCRIPTION WHAT SHOULD IT DO.
/*
Task Description:
I need to read from a text file, every uneven line number is a user and every even line number is a score. each of these arrays must be seperate. Array, users and scores. This array must be sorted using bubblesort.
Then printed into each ones own textarea, with a button to click to sort.
*/
//-
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintStream;
/**/import javax.swing.filechooser.*;
import java.util.StringTokenizer;
import java.lang.Object;
/**/import javax.swing.*;//--
/**/import javax.swing.event.*;//--
/**/import java.io.File;//--
/**/import java.awt.*;//--
/**/import java.awt.event.*;//--
/**/import java.io.*;//--
//-
class Taak15March07extends JFrameimplements ActionListener
{
JButton button =new JButton ("Sort");
JTextArea textarea =new JTextArea (20, 10);
public Taak15March07 ()
{
super ("My Taak Vir IT");
setSize (1000, 500);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setVisible (true);
Container content = getContentPane ();
FlowLayout layout =new FlowLayout ();
content.setLayout (layout);
button.addActionListener (this);
content.add (button);
content.add (textarea);
setContentPane (content);
}
publicvoid actionPerformed (ActionEvent event)
{
String str ="From: " + event.getActionCommand ();
if (event.getSource () == button)
str +=" - No. 1";
textarea.setText (str);
}
publicstaticvoid main (String [] args)throws Exception
{
Taak15March07 eg =new Taak15March07 ();
Taak15March07 f =new Taak15March07 ();
f.readMyFile ();
}
java.io.File cdlist =new java.io.File("mydata.txt");
FileReader infile =new FileReader(cdlist);
//FileWriter outfile = new FileWriter("newlist.txt");
BufferedReader br =new BufferedReader(infile);
//BufferedWriter out = new BufferedWriter(new FileWriter("newlist.txt"));
if (cdlist.exists()){
String [] textArray =new String[99];
String line;
int lineNum = 0;
while ((line = br.readLine()) !=null){
textArray[lineNum++] = line;
/*System.out.println*/textarea.setText(line);
}
int numOfCds = 1;
int boxNum = 1;
int boxPos = 1;
int cdsPerBox = 20;
out.write("Contents of Box " + boxNum);
out.newLine();
out.newLine();
for(int i = 0; i<textArray.length; i++){
out.write(textArray[i] +" box position: " + boxPos +"\n");
out.newLine();
boxPos++;
numOfCds++;
if (boxPos >= cdsPerBox){
boxNum++;
out.newLine();
out.newLine();
out.write("Contents of Box " + boxNum);
out.newLine();
out.newLine();
boxPos = 1;
}
}
infile.close();
out.close();
}else{
System.out.println("file not found, program terminating");
System.exit(0);
}
}
}
MYDATA.TXT CONTAINS:
jan
100
john
357
noob
3258
gudon
9999
netspike
9811
frogboy
135
seraphs
1
Any help from you java wizards will be appreciated!

