Exemplo n.º 1
0
 private static Reader bomCheck(InputStream in) throws IOException {
   UnicodeBOMInputStream bomStream = new UnicodeBOMInputStream(in);
   if (bomStream.getBOM() != UnicodeBOMInputStream.BOM.NONE) {
     return new BufferedReader(new InputStreamReader(bomStream.skipBOM()));
   } else {
     return new BufferedReader(new InputStreamReader(bomStream));
   }
 }
Exemplo n.º 2
0
  private static Reader bomCheck(File fromPath) throws IOException {
    UnicodeBOMInputStream bomStream = new UnicodeBOMInputStream(new FileInputStream(fromPath));
    if (bomStream.getBOM() != UnicodeBOMInputStream.BOM.NONE) {
      return new BufferedReader(new InputStreamReader(bomStream.skipBOM()));
    } else {
      return new BufferedReader(new InputStreamReader(bomStream));
    }

    /*
    StreamSource bomcheck = new StreamSource(new FileReader(fromPath));
    Reader reader = new BufferedReader(bomcheck.getReader());
    try {
      removeBOM(reader);
      return reader;
    }
    catch (Exception e) {
      throw new IOException("Cannot remove byte-order-mark from XML file");
    }
    */
  }