@@ -29,6 +29,7 @@ public static Homoglyph build() throws IOException {
29
29
throw new MissingResourceException ("Unable to read " + CHAR_CODES_FILE ,
30
30
HomoglyphBuilder .class .getName (), CHAR_CODES_FILE );
31
31
}
32
+
32
33
return build (new InputStreamReader (is ));
33
34
}
34
35
@@ -58,23 +59,24 @@ public static Homoglyph build(final String path) throws IOException {
58
59
*/
59
60
public static Homoglyph build (final Reader reader ) throws IOException {
60
61
final List <Set <Integer >> homoglyphs = new ArrayList <Set <Integer >>();
61
- final BufferedReader bufferedReader = new BufferedReader (reader );
62
62
63
- String line ;
64
- while ((line = bufferedReader .readLine ()) != null ){
65
- line = line .trim ();
66
- if (line .startsWith ("#" ) || line .length () == 0 ){
67
- continue ;
68
- }
69
- final Set <Integer > set = new HashSet <Integer >();
70
- for (String charCode : line .split ("," )) {
71
- try {
72
- set .add (Integer .parseInt (charCode , 16 ));
73
- } catch (NumberFormatException ex ){
74
- // ignore badly formatted lines
63
+ try (final BufferedReader bufferedReader = new BufferedReader (reader )) {
64
+ String line ;
65
+ while ((line = bufferedReader .readLine ()) != null ){
66
+ line = line .trim ();
67
+ if (line .startsWith ("#" ) || line .length () == 0 ){
68
+ continue ;
69
+ }
70
+ final Set <Integer > set = new HashSet <Integer >();
71
+ for (String charCode : line .split ("," )) {
72
+ try {
73
+ set .add (Integer .parseInt (charCode , 16 ));
74
+ } catch (NumberFormatException ex ){
75
+ // ignore badly formatted lines
76
+ }
75
77
}
78
+ homoglyphs .add (set );
76
79
}
77
- homoglyphs .add (set );
78
80
}
79
81
80
82
return new Homoglyph (homoglyphs );
0 commit comments