Package org.apache.commons.io.input

Examples of org.apache.commons.io.input.BOMInputStream


    }
    public static InputStreamReader getInputStreamReader(File file, String encoding) throws IOException {
       
        FileInputStream fis = new FileInputStream(file);
        logger.info("Reading file: " + file + " using encoding: " + encoding);
        BOMInputStream bis = new BOMInputStream(fis); //So that we can remove the BOM
        return new InputStreamReader(bis, encoding);
    }
View Full Code Here


   */
  private String getResourceContent(final Resource resource)
      throws IOException {
    InputStream is = null;
    try {
      is = new BOMInputStream(uriLocatorFactory.locate(resource.getUri()));
      final String result = IOUtils.toString(is, context.getConfig().getEncoding());
      if (StringUtils.isEmpty(result)) {
        LOG.debug("Empty resource detected: {}", resource.getUri());
      }
      return result;
View Full Code Here

    public LessSource(File input) throws IOException {
        this( new FileResource(input) );
    }

    private String loadResource(Resource resource, Charset charset) throws IOException {
        BOMInputStream inputStream = new BOMInputStream( resource.getInputStream() );
        try {
            if( inputStream.hasBOM() ) {
                logger.debug("BOM found %s", inputStream.getBOMCharsetName());
                return IOUtils.toString(inputStream, inputStream.getBOMCharsetName());
            } else {
                logger.debug("Using charset " + charset.name());
                return IOUtils.toString(inputStream, charset.name());
            }
        }
        finally {
            inputStream.close();
        }
    }
View Full Code Here

    List<AfcFile> afcFiles = new ArrayList<AfcFile>();
    List<String> files = new ArrayList<String>();
    Collections.addAll(files, file.list(new SuffixFileFilter(".afc")));
    Collections.sort(files);
    for (String fileName : files) {
      InputStreamReader reader = new InputStreamReader(new BOMInputStream(new FileInputStream(new File(file,
          fileName))), "UTF-8");
      afcFiles.add(new AfcFile(reader, fileName));
    }
    return afcFiles;
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.io.input.BOMInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.