/** * Creates a {@link Reader} for reading content of the file use the default charset {@link Charsets#defaultCharset()}. * * <p> * Note : * <strong> * You must close the retured {@link Reader}. * </strong> * * @throws NestedIOException if an I/O error occurs. */ public static Reader createReader(File file) throws NestedIOException{ return createReader(file,Charsets.defaultCharset()); }
/** * Reads the given properties file. * * @throws NestedIOException if an I/O error occurs. */ public static ExProperties load(File file,Properties defaults) throws NestedIOException { Args.notNull(file,"file"); try { ExProperties props = null == defaults ? new ExProperties(file) : new ExProperties(file,defaults); if(Strings.endsWithIgnoreCase(file.getName(), ".xml")){ try(InputStream in = new FileInputStream(file)){ props.loadFromXML(in); } }else{ try(Reader reader = IO.createReader(file,Charset.defaultCharset())){ props.load(reader); } } return props; } catch (IOException e) { throw new NestedIOException("Error loading properties file '" + file.getAbsolutePath() + "', " + e.getMessage(), e); } }