所以我一直在研究一个监视URL的监视器,它检查URL的末尾是否有“/ Password” - 如果有,打印出url中没有密码,如果有的话,几秒后重试随机。
有时我发生的事情是,当我检查时,我有时会遇到Maxretries错误,导致我收到错误并杀死脚本。我想做和做的是每当出现错误时 - 再次重试,现在我想问问你们我是否做得正确或是否有比这更好的方法?
public class Test_korn
{
public static void main(String[] args)
{
double grain ,gram, kilo, ton, container, ship;
int i;
grain = 1;
i = 1;
System.out.println( i + ". field: " + (int) grain + " grains" );
while(i <= 63) // 2^0 = 1 bis 2^63!
{
grain *= 2 ;
if (grain/100 <= 1)
{
System.out.println( (i+1) + ". field: " + (int) grain + " grains" );
}
else if( grain/100 > 1 && grain/10_000 <= 1 )
{
gram = grain/10;
System.out.println( (i+1) + ". field: " + gram + " grams" );
}
else if( grain/10_000 > 1 && grain/(10_000 * 1000) <= 1)
{
kilo = grain/(10 * 1000);
System.out.println( (i+1) + ". field: " + kilo + " kilogram" );
}
else if( grain/(10_000 * 1000) > 1 && grain/(10_000 * 1000 * 1000) <= 1 )
{
ton = grain/( 10 * 1000 * 1000);
System.out.println( (i+1) + ". field: " + ton + " tons" );
}
else if( grain/(10_000 * 1000 * 1000) > 1 && grain/(10_000 * 1000 * 1000 * 1000) <= 1 )
{
container = grain/(10 * 1000 * 1000 *1000);
System.out.println( (i+1) + ". field: " + container + " container" );
}
else if( grain/(10_000 * 1000 * 1000 * 1000) > 1 )
{
ship = grain/(10000 * 1000 * 1000 * 1000 * 1000);
System.out.println( (i+1) + ". field: " + ship + "container ship" );
}
i++;
}
}
}