我的程序中有一个while循环,它仅在某个条件变为真时才执行操作,但在那之前它什么都不做。每次运行循环时,我都会在控制台中打印“运行”一词,但这不再是必需的。当我删除 system.out.println 循环立即关闭并停止工作。为什么会这样?
int INFINITE = 1;
try {
S3Object object = s3.getObject(new GetObjectRequest("saucyMMO", "logins.txt"));
while (INFINITE == 1) {
System.out.println();
if (tryToLogin == true) {
INFINITE = 0;
BufferedReader br = new BufferedReader(
new InputStreamReader(object.getObjectContent()));
String lineValue = null;
while((lineValue = br.readLine()) != null && loggedInAs == null) {
String splitResult[] = lineValue.split(",");
boolean retVal = splitResult[0].equals(ui.usernameLogin.getText());
boolean retVal2 = splitResult[1].equals(ui.passwordLogin.getText());
if (retVal == true && retVal2 == true) {
loggedInAs = splitResult[0];
System.out.println("logged in as : " + loggedInAs);
} else if (retVal && !retVal2){
System.out.println("User exists, but password is incorrect");
} else {
}
}
}
}
} catch (AmazonServiceException ase) {
} catch (AmazonClientException ace) {
} catch (IOException e) {
e.printStackTrace();
}
我为 AmazonServiceException 和 AmazonClientException 添加了异常处理,但无论是否使用 system.out.println,我都没有收到任何错误。