Code example for FileWriter

Methods: close, write

0
  /* 
   * Test if spaces are allowed in host names 
   */ 
  @Test 
  public void testHostFileReaderWithSpaces() throws Exception { 
    FileWriter efw = new FileWriter(excludesFile);
    FileWriter ifw = new FileWriter(includesFile);
 
    efw.write("#DFS-Hosts-excluded\n");
    efw.write("   somehost somehost2");
    efw.write("   somehost3 # somehost4");
    efw.close();
 
    ifw.write("#Hosts-in-DFS\n");
    ifw.write("   somehost somehost2");
    ifw.write("   somehost3 # somehost4");
    ifw.close();
 
    HostsFileReader hfp = new HostsFileReader(includesFile, excludesFile);
 
    int includesLen = hfp.getHosts().size();