Sie sind auf Seite 1von 1

Another cool thing to do with modulo is when you are doing big processes, you ca

n let the user know that your program isn't stuck:


TextFileIn f = new TextFileIn("bigfile.txt");
int numLines = 0 ;
boolean done = false ;
while( ! done )
{
String s = f.readLine();
if ( s == null )
{
done = true ;
}
else
{
// processing the big file goes here
numLines++;
if ( ( numLines % 1000 ) == 0 )
{
System.out.print(".");
}
}
}
This program fragment will read in a file, process it, and write a dot to the sc
reen for every 1000 lines processed.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
---

Das könnte Ihnen auch gefallen