@Test public void testFileNotFound() throws Exception { assertEquals("", ResolverConfReader.getDomainFromResolverConf( "/this_file_really-ShoUldnt=exist")); }
public static String getDomainFromResolverConf(final String file) { try (final InputStream in = new FileInputStream(file)) { final InputStreamReader isr = new InputStreamReader(in); try (final BufferedReader br = new BufferedReader(isr)) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("domain")) { final StringTokenizer st = new StringTokenizer(line); st.nextToken(); if (!st.hasMoreTokens()) { continue; } return st.nextToken(); } } } } catch (FileNotFoundException e) { log.warn("Resolver config file not found", e); } catch (IOException e) { log.warn("Error reading config file", e); } return ""; }
ResolverConfReader { public static String getDomainFromResolverConf(final String file) { try (final InputStream in = new FileInputStream(file)) { final InputStreamReader isr = new InputStreamReader(in); try (final BufferedReader br = new BufferedReader(isr)) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("domain")) { final StringTokenizer st = new StringTokenizer(line); st.nextToken(); if (!st.hasMoreTokens()) { continue; } return st.nextToken(); } } } } catch (FileNotFoundException e) { log.warn("Resolver config file not found", e); } catch (IOException e) { log.warn("Error reading config file", e); } return ""; } }
ResolverConfReader { public static String getDomainFromResolverConf(final String file) { try (final InputStream in = new FileInputStream(file)) { final InputStreamReader isr = new InputStreamReader(in); try (final BufferedReader br = new BufferedReader(isr)) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("domain")) { final StringTokenizer st = new StringTokenizer(line); st.nextToken(); if (!st.hasMoreTokens()) { continue; } return st.nextToken(); } } } } catch (FileNotFoundException e) { log.warn("Resolver config file not found", e); } catch (IOException e) { log.warn("Error reading config file", e); } return ""; }  }
ResolverConfReader { public static String getDomainFromResolverConf(final String file) { try (final InputStream in = new FileInputStream(file)) { final InputStreamReader isr = new InputStreamReader(in); try (final BufferedReader br = new BufferedReader(isr)) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("domain")) { final StringTokenizer st = new StringTokenizer(line); st.nextToken(); if (!st.hasMoreTokens()) { continue; } return st.nextToken(); } } } } catch (FileNotFoundException e) { log.warn("Resolver config file not found", e); } catch (IOException e) { log.warn("Error reading config file", e); } return ""; }  static String getDomainFromResolverConf(final String file); }
ResolverConfReader { public static String getDomainFromResolverConf(final String file) { try (final InputStream in = new FileInputStream(file)) { final InputStreamReader isr = new InputStreamReader(in); try (final BufferedReader br = new BufferedReader(isr)) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("domain")) { final StringTokenizer st = new StringTokenizer(line); st.nextToken(); if (!st.hasMoreTokens()) { continue; } return st.nextToken(); } } } } catch (FileNotFoundException e) { log.warn("Resolver config file not found", e); } catch (IOException e) { log.warn("Error reading config file", e); } return ""; }  static String getDomainFromResolverConf(final String file);  }