mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Use StringWriter to prevent race condition in println
This commit is contained in:
parent
1fbefcac31
commit
70ee6c601c
|
@ -34,6 +34,7 @@ import com.google.zxing.multi.MultipleBarcodeReader;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -149,21 +150,30 @@ final class DecodeWorker implements Callable<Integer> {
|
||||||
if (config.brief) {
|
if (config.brief) {
|
||||||
System.out.println(uri + ": Success");
|
System.out.println(uri + ": Success");
|
||||||
} else {
|
} else {
|
||||||
for (Result result : results) {
|
StringWriter output = new StringWriter();
|
||||||
|
for (int resultIndex = 0; resultIndex < results.length; resultIndex++) {
|
||||||
|
Result result = results[resultIndex];
|
||||||
ParsedResult parsedResult = ResultParser.parseResult(result);
|
ParsedResult parsedResult = ResultParser.parseResult(result);
|
||||||
System.out.println(uri +
|
output.write(uri +
|
||||||
" (format: " + result.getBarcodeFormat() +
|
" (format: " + result.getBarcodeFormat() +
|
||||||
", type: " + parsedResult.getType() + "):\n" +
|
", type: " + parsedResult.getType() + "):\n" +
|
||||||
"Raw result:\n" +
|
"Raw result:\n" +
|
||||||
result.getText() + "\n" +
|
result.getText() + "\n" +
|
||||||
"Parsed result:\n" +
|
"Parsed result:\n" +
|
||||||
parsedResult.getDisplayResult());
|
parsedResult.getDisplayResult() + "\n");
|
||||||
System.out.println("Found " + result.getResultPoints().length + " result points.");
|
output.write("Found " + result.getResultPoints().length + " result points.\n");
|
||||||
for (int i = 0; i < result.getResultPoints().length; i++) {
|
for (int pointIndex = 0; pointIndex < result.getResultPoints().length; pointIndex++) {
|
||||||
ResultPoint rp = result.getResultPoints()[i];
|
ResultPoint rp = result.getResultPoints()[pointIndex];
|
||||||
System.out.println(" Point " + i + ": (" + rp.getX() + ',' + rp.getY() + ')');
|
output.write(" Point " + pointIndex + ": (" + rp.getX() + ',' + rp.getY() + ')');
|
||||||
|
if (pointIndex != result.getResultPoints().length - 1) {
|
||||||
|
output.write('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (resultIndex != results.length - 1) {
|
||||||
|
output.write('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
Loading…
Reference in a new issue