I'm having a small problem getting variables from outfiles to produce a Dialog Box. I have to get the number of teams in each outfile and print them out in a dialog box. Along with the best and worst team based on their win percentage. The book I have explains nothing on the subject, nor has the web been any help so far. Anyone have any suggestions on where I'm going wrong? Heres my code:
I didnt understand why you did inFile.readLine() 2-3 times instead of looping over the inFile. Also, if outFile and outLossFile are going to contain more than one record, you will have to manually enter a newline after writing each line to the file.
Also, if you use BufferedWriter bw = new FileWriter("filename"), then you the adv. of buffering. Without buffering, each invocation of a print() method would cause characters to be converted into bytes that would then be written immediately to the file, which can be very inefficient.
Was that helpful?
Joined: Oct 14, 2004
Ok, I understand where your coming from I'm new to java so don't really know all the short forms and such so some of the programs i write are really long, for no particular reason. I have the program going like it should taking the list from infile, calculating all the win percentages, then outputting into the two seperate outfiles based on their win percentage. Now what i need to get is the count of the winning and the count of the losing teams within each file, and output it..What I'm thinking is I need a count++; within the if..else statement but I'm not sure.When i put it in there i get a bunch of no if without else errors..no matter how many times ive played with the curly bracers.
Every iteration of the loop over the input file will write something to one of the two output files.
If you are interested in getting a line count of each of the files (ie, if each line represents a team), then you need another loop over each of those files in a similar way as I did over the input file and do count++.
So after your first loop of input file...add two more while() loops one each for outfile and outlossfile and within that whileloop do count++
Unless...theres some API to count lines in a file which Im not aware of.
Hoep that was helpful. If not, write back again. Amit
Joined: Oct 14, 2004
On your last post , I'm unclear on what you think i should do with the two while loops to count the teams in each file.
Ok, got the counter to work finally..had a problem with my curly braces..things can get annoying sometimes . [ October 21, 2004: Message edited by: Shawn Houston ]