/** * Parse a hosts file using the system default {@link Charset} for decoding. * * @param file the file to be parsed * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file) throws IOException { return parse(file, Charset.defaultCharset()); }
throw new IOException(); entries = HostsFileParser.parse(file); } catch (IOException e) { throw new VertxException("Cannot read hosts file " + file.getAbsolutePath()); entries = HostsFileParser.parse(new StringReader(options.getHostsValue().toString())); } catch (IOException e) { throw new VertxException("Cannot read hosts config ", e);
/** * Parse a hosts file using the system default {@link Charset} for decoding. * * @param file the file to be parsed * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file) throws IOException { return parse(file, Charset.defaultCharset()); }
throw new IOException(); entries = HostsFileParser.parse(file); } catch (IOException e) { throw new VertxException("Cannot read hosts file " + file.getAbsolutePath()); entries = HostsFileParser.parse(new StringReader(options.getHostsValue().toString())); } catch (IOException e) { throw new VertxException("Cannot read hosts config ", e);
/** * Parse hosts file at standard OS location using the system default {@link Charset} for decoding. * * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse() throws IOException { return parse(locateHostsFile()); }
/** * Parse hosts file at standard OS location using the system default {@link Charset} for decoding. * * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse() throws IOException { return parse(locateHostsFile()); }
/** * Parse a hosts file. * * @param file the file to be parsed * @param charsets the {@link Charset}s to try as file encodings when parsing. * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file, Charset... charsets) throws IOException { checkNotNull(file, "file"); checkNotNull(charsets, "charsets"); if (file.exists() && file.isFile()) { for (Charset charset: charsets) { HostsFileEntries entries = parse(new BufferedReader(new InputStreamReader( new FileInputStream(file), charset))); if (entries != HostsFileEntries.EMPTY) { return entries; } } } return HostsFileEntries.EMPTY; }
/** * Parse hosts file at standard OS location. * * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse() throws IOException { return parse(locateHostsFile()); }
/** * Parse a hosts file. * * @param file the file to be parsed * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file) throws IOException { checkNotNull(file, "file"); if (file.exists() && file.isFile()) { return parse(new BufferedReader(new FileReader(file))); } else { return HostsFileEntries.EMPTY; } }
/** * Parse a hosts file. * * @param file the file to be parsed * @param charsets the {@link Charset}s to try as file encodings when parsing. * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file, Charset... charsets) throws IOException { checkNotNull(file, "file"); checkNotNull(charsets, "charsets"); if (file.exists() && file.isFile()) { for (Charset charset: charsets) { HostsFileEntries entries = parse(new BufferedReader(new InputStreamReader( new FileInputStream(file), charset))); if (entries != HostsFileEntries.EMPTY) { return entries; } } } return HostsFileEntries.EMPTY; }
/** * Parse hosts file at standard OS location using the given {@link Charset}s one after each other until * we were able to parse something or none is left. * * @param charsets the {@link Charset}s to try as file encodings when parsing. * @return a {@link HostsFileEntries} */ public static HostsFileEntries parseSilently(Charset... charsets) { File hostsFile = locateHostsFile(); try { return parse(hostsFile, charsets); } catch (IOException e) { if (logger.isWarnEnabled()) { logger.warn("Failed to load and parse hosts file at " + hostsFile.getPath(), e); } return HostsFileEntries.EMPTY; } }
/** * Parse hosts file at standard OS location using the given {@link Charset}s one after each other until * we were able to parse something or none is left. * * @param charsets the {@link Charset}s to try as file encodings when parsing. * @return a {@link HostsFileEntries} */ public static HostsFileEntries parseSilently(Charset... charsets) { File hostsFile = locateHostsFile(); try { return parse(hostsFile, charsets); } catch (IOException e) { if (logger.isWarnEnabled()) { logger.warn("Failed to load and parse hosts file at " + hostsFile.getPath(), e); } return HostsFileEntries.EMPTY; } }
/** * Parse hosts file at standard OS location. * * @return a {@link HostsFileEntries} */ public static HostsFileEntries parseSilently() { File hostsFile = locateHostsFile(); try { return parse(hostsFile); } catch (IOException e) { if (logger.isWarnEnabled()) { logger.warn("Failed to load and parse hosts file at " + hostsFile.getPath(), e); } return HostsFileEntries.EMPTY; } }
/** * Parse a hosts file using the system default {@link Charset} for decoding. * * @param file the file to be parsed * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file) throws IOException { return parse(file, Charset.defaultCharset()); }
/** * Parse hosts file at standard OS location. * * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse() throws IOException { return parse(locateHostsFile()); }
/** * Parse hosts file at standard OS location using the system default {@link Charset} for decoding. * * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse() throws IOException { return parse(locateHostsFile()); }
/** * Parse a hosts file. * * @param file the file to be parsed * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file) throws IOException { checkNotNull(file, "file"); if (file.exists() && file.isFile()) { return parse(new BufferedReader(new FileReader(file))); } else { return HostsFileEntries.EMPTY; } }
/** * Parse hosts file at standard OS location. * * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse() throws IOException { return parse(locateHostsFile()); }
/** * Parse a hosts file. * * @param file the file to be parsed * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse(File file) throws IOException { checkNotNull(file, "file"); if (file.exists() && file.isFile()) { return parse(new BufferedReader(new FileReader(file))); } else { return HostsFileEntries.EMPTY; } }
/** * Parse hosts file at standard OS location. * * @return a {@link HostsFileEntries} * @throws IOException file could not be read */ public static HostsFileEntries parse() throws IOException { return parse(locateHostsFile()); }