Replace Java7+ code constructs with Java6 equivalents.

pull/35/head
Guillermo Rodríguez 7 years ago
parent 01f1b9de8c
commit 493eea3eec

@ -64,10 +64,13 @@ public final class QrCodeGeneratorDemo {
ImageIO.write(img, "png", imgFile); // Write image to file ImageIO.write(img, "png", imgFile); // Write image to file
String svg = qr.toSvgString(4); // Convert to SVG XML code String svg = qr.toSvgString(4); // Convert to SVG XML code
try (Writer out = new OutputStreamWriter( Writer out = new OutputStreamWriter(
new FileOutputStream("hello-world-QR.svg"), new FileOutputStream("hello-world-QR.svg"),
StandardCharsets.UTF_8)) { StandardCharsets.UTF_8);
try {
out.write(svg); // Create/overwrite file and write SVG data out.write(svg); // Create/overwrite file and write SVG data
} finally {
try { out.close(); } catch (IOException e) { }
} }
} }

@ -38,10 +38,10 @@ public final class QrCodeGeneratorWorker {
public static void main(String[] args) { public static void main(String[] args) {
// Set up input stream and start loop // Set up input stream and start loop
try (Scanner input = new Scanner(System.in, "US-ASCII")) { Scanner input = new Scanner(System.in, "US-ASCII");
input.useDelimiter("\r\n|\n|\r"); input.useDelimiter("\r\n|\n|\r");
while (processCase(input)); while (processCase(input));
} input.close();
} }

@ -118,7 +118,7 @@ public final class QrSegment {
Objects.requireNonNull(text); Objects.requireNonNull(text);
// Select the most efficient segment encoding automatically // Select the most efficient segment encoding automatically
List<QrSegment> result = new ArrayList<>(); List<QrSegment> result = new ArrayList<QrSegment>();
if (text.equals("")); // Leave result empty if (text.equals("")); // Leave result empty
else if (NUMERIC_REGEX.matcher(text).matches()) else if (NUMERIC_REGEX.matcher(text).matches())
result.add(makeNumeric(text)); result.add(makeNumeric(text));

@ -174,7 +174,7 @@ public final class QrSegmentAdvanced {
private static List<QrSegment> splitIntoSegments(byte[] data, QrSegment.Mode[] charModes) { private static List<QrSegment> splitIntoSegments(byte[] data, QrSegment.Mode[] charModes) {
List<QrSegment> result = new ArrayList<>(); List<QrSegment> result = new ArrayList<QrSegment>();
if (data.length == 0) if (data.length == 0)
return result; return result;

Loading…
Cancel
Save