File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
barcodes/src/main/java/com/itextpdf/barcodes Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -329,13 +329,11 @@ public static int getChecksum(String text) {
329
329
if (text == null ) {
330
330
throw new IllegalArgumentException ("Valid code required to generate checksum for MSI barcode" );
331
331
}
332
- String [] strArray = text .split ("" );
333
- int [] digits = new int [strArray .length ];
334
- for (int i = 0 ; i < strArray .length ; i ++) {
335
- try {
336
- digits [i ] = Integer .parseInt (strArray [i ]);
337
- } catch (NumberFormatException e ) {
338
- throw new IllegalArgumentException ("The character " + text .charAt (i ) + " is illegal in MSI bar codes." );
332
+ int [] digits = new int [text .length ()];
333
+ for (int x = 0 ; x < text .length (); x ++) {
334
+ digits [x ] = (int )(text .charAt (x ) - '0' );
335
+ if (digits [x ] < 0 || digits [x ] > 9 ) {
336
+ throw new IllegalArgumentException ("The character " + text .charAt (x ) + " is illegal in MSI bar codes." );
339
337
}
340
338
}
341
339
int sum = 0 ;
You can’t perform that action at this time.
0 commit comments