mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Tiny changes to System.err usage, closed a stream, saved a reused Pattern
git-svn-id: https://zxing.googlecode.com/svn/trunk@1064 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
77a263dd91
commit
7d0acf8bd9
|
@ -75,7 +75,7 @@ public final class CommandLineRunner {
|
|||
} else if ("--dump_black_point".equals(arg)) {
|
||||
dumpBlackPoint = true;
|
||||
} else if (arg.startsWith("-")) {
|
||||
System.out.println("Unknown command line option " + arg);
|
||||
System.err.println("Unknown command line option " + arg);
|
||||
printUsage();
|
||||
return;
|
||||
}
|
||||
|
@ -106,11 +106,11 @@ public final class CommandLineRunner {
|
|||
}
|
||||
|
||||
private static void printUsage() {
|
||||
System.out.println("Decode barcode images using the ZXing library\n");
|
||||
System.out.println("usage: CommandLineRunner { file | dir | url } [ options ]");
|
||||
System.out.println(" --try_harder: Use the TRY_HARDER hint, default is normal (mobile) mode");
|
||||
System.out.println(" --dump_results: Write the decoded contents to input.txt");
|
||||
System.out.println(" --dump_black_point: Compare black point algorithms as input.mono.png");
|
||||
System.err.println("Decode barcode images using the ZXing library\n");
|
||||
System.err.println("usage: CommandLineRunner { file | dir | url } [ options ]");
|
||||
System.err.println(" --try_harder: Use the TRY_HARDER hint, default is normal (mobile) mode");
|
||||
System.err.println(" --dump_results: Write the decoded contents to input.txt");
|
||||
System.err.println(" --dump_black_point: Compare black point algorithms as input.mono.png");
|
||||
}
|
||||
|
||||
private static void decodeOneArgument(String argument, Hashtable<DecodeHintType, Object> hints,
|
||||
|
@ -282,13 +282,22 @@ public final class CommandLineRunner {
|
|||
resultName = resultName.substring(0, pos);
|
||||
}
|
||||
resultName += ".mono.png";
|
||||
OutputStream outStream = null;
|
||||
try {
|
||||
OutputStream outStream = new FileOutputStream(resultName);
|
||||
outStream = new FileOutputStream(resultName);
|
||||
ImageIO.write(result, "png", outStream);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("Could not create " + resultName);
|
||||
System.err.println("Could not create " + resultName);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Could not write to " + resultName);
|
||||
System.err.println("Could not write to " + resultName);
|
||||
} finally {
|
||||
try {
|
||||
if (outStream != null) {
|
||||
outStream.close();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public final class ImageConverter {
|
|||
} else if ("-2d".equals(arg)) {
|
||||
rowSampling = false;
|
||||
} else if (arg.startsWith("-")) {
|
||||
System.out.println("Ignoring unrecognized option: " + arg);
|
||||
System.err.println("Ignoring unrecognized option: " + arg);
|
||||
}
|
||||
}
|
||||
for (String arg : args) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* A {@link Filter} that rejects requests from hosts that are sending too many
|
||||
|
@ -45,6 +46,7 @@ public final class DoSFilter implements Filter {
|
|||
private static final int MAX_ACCESSES_PER_IP_PER_TIME = 10;
|
||||
private static final long MAX_ACCESS_INTERVAL_MSEC = 10L * 1000L;
|
||||
private static final long UNBAN_INTERVAL_MSEC = 60L * 60L * 1000L;
|
||||
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
||||
|
||||
private final IPTrie numRecentAccesses;
|
||||
private final Timer timer;
|
||||
|
@ -63,7 +65,7 @@ public final class DoSFilter implements Filter {
|
|||
context = filterConfig.getServletContext();
|
||||
String bannedIPs = filterConfig.getInitParameter("bannedIPs");
|
||||
if (bannedIPs != null) {
|
||||
for (String ip : bannedIPs.split(",")) {
|
||||
for (String ip : COMMA_PATTERN.split(bannedIPs)) {
|
||||
manuallyBannedIPAddresses.add(ip.trim());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue