Hi... I'm a newbie at Java, so I was wondering if you guys could help me out...
I have txt file i'm reading scores and labels off of to make a bar graph.
First line is an integer (score), second line is the label ("Score 1"), and they alternate from then on. I have 5 scores, meaning ten lines in the txt file.
Anyway, I can read the txt file and make the bar graph perfectly, but when i make the loop, i always have to specify how many times to do the loop... I have no idea how to make it count how many items are in the txt file automatically or to stop when there are no more values.
Please help if you can :o
Here is my code for the loop area so far:
int n = 0;
int itemCount = 5;
SimpleReader reader = new SimpleReader( "graphdata.dat" );
while ( n < itemCount )
{
double number = reader.getInt();
r = new SimpleRectangle( BAR_START, barPos, (int) number, BAR_HEIGHT );
r.setColor( barColor );
r.setToFill();
graphWin.add( r );
total = total + number;
n = n + 1;
barPos = barPos + BAR_HEIGHT + BAR_SPACER;
String word = reader.getString();
lab = new SimpleLabel( LABEL_START, labelPos, LABEL_WIDTH, LABEL_HEIGHT );
lab.setText( word + ": " + (int) number );
graphWin.add( lab );
labelPos = labelPos + LABEL_HEIGHT + LABEL_SPACER;
}
reader.safeClose();
LP cores are MUCH lower power than Efficiency cores. Efficiency cores never really lived up to their name, but they did add a meaningful amount of performance in multithreaded loads, so Intel isn't going to remove them.
I don't usually say this, but WTF Microsoft?! Do you hate your customers, or do you just really not care at all? Windows Hello is one of the useful Windows features, and now you're effing it up.
Question
khaos34
Hi... I'm a newbie at Java, so I was wondering if you guys could help me out...
I have txt file i'm reading scores and labels off of to make a bar graph.
First line is an integer (score), second line is the label ("Score 1"), and they alternate from then on. I have 5 scores, meaning ten lines in the txt file.
Anyway, I can read the txt file and make the bar graph perfectly, but when i make the loop, i always have to specify how many times to do the loop... I have no idea how to make it count how many items are in the txt file automatically or to stop when there are no more values.
Please help if you can :o
Here is my code for the loop area so far:
Link to comment
https://www.neowin.net/forum/topic/62996-java-reading-file-loop-help/Share on other sites
6 answers to this question
Recommended Posts