Updated Java worker program to close input stream and reduce indentation.
This commit is contained in:
parent
9628e25971
commit
0f73afa367
|
@ -38,14 +38,18 @@ public final class QrCodeGeneratorWorker {
|
|||
|
||||
public static void main(String[] args) {
|
||||
// Set up input stream and start loop
|
||||
Scanner input = new Scanner(System.in, "US-ASCII");
|
||||
try (Scanner input = new Scanner(System.in, "US-ASCII")) {
|
||||
input.useDelimiter("\r\n|\n|\r");
|
||||
while (true) {
|
||||
while (processCase(input));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean processCase(Scanner input) {
|
||||
// Read data length or exit
|
||||
int length = input.nextInt();
|
||||
if (length == -1)
|
||||
break;
|
||||
return false;
|
||||
if (length > Short.MAX_VALUE)
|
||||
throw new RuntimeException();
|
||||
|
||||
|
@ -93,7 +97,7 @@ public final class QrCodeGeneratorWorker {
|
|||
System.out.println(-1);
|
||||
}
|
||||
System.out.flush();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue