Code example for FileWriter

Methods: close, write

0
  /* 
   * Check if only comments can be written to hosts file 
   */ 
  @Test 
  public void testHostFileReaderWithCommentsOnly() throws Exception { 
    FileWriter efw = new FileWriter(excludesFile);
    FileWriter ifw = new FileWriter(includesFile);
 
    efw.write("#DFS-Hosts-excluded\n");
    efw.close();
 
    ifw.write("#Hosts-in-DFS\n");
    ifw.close();
 
    HostsFileReader hfp = new HostsFileReader(includesFile, excludesFile);
 
    int includesLen = hfp.getHosts().size();
    int excludesLen = hfp.getExcludedHosts().size();
 
    assertEquals(0, includesLen);
    assertEquals(0, excludesLen);