@@ -40,16 +40,7 @@ private String load(String fileName, String encoding) throws IOException {
4040 if (fileName != null ) {
4141 File f = new File (fileName );
4242 int size = (int ) f .length ();
43- try (BOMInputStream input =
44- new BOMInputStream (
45- new FileInputStream (fileName ),
46- false ,
47- ByteOrderMark .UTF_8 ,
48- ByteOrderMark .UTF_16LE ,
49- ByteOrderMark .UTF_16BE ,
50- ByteOrderMark .UTF_32LE ,
51- ByteOrderMark .UTF_32BE )) {
52-
43+ try (BOMInputStream input = bomInputStream (fileName ).get ()) {
5344 ByteOrderMark bom = input .getBOM ();
5445 if (bom != null ) {
5546 encoding = bom .getCharsetName ();
@@ -76,4 +67,16 @@ public String getSourceName() {
7667 public String getEncoding () {
7768 return this .encoding ;
7869 }
70+
71+ private static BOMInputStream .Builder bomInputStream (String fileName ) throws IOException {
72+ return BOMInputStream .builder ()
73+ .setInputStream (new FileInputStream (fileName ))
74+ .setInclude (false )
75+ .setByteOrderMarks (
76+ ByteOrderMark .UTF_8 ,
77+ ByteOrderMark .UTF_16LE ,
78+ ByteOrderMark .UTF_16BE ,
79+ ByteOrderMark .UTF_32LE ,
80+ ByteOrderMark .UTF_32BE );
81+ }
7982}
0 commit comments