### Question:
FileWriterUtil { private Writer getWriter(File fn) throws IOException { return getWriter(fn, StandardCharsets.UTF_8.name()); } FileWriterUtil();  FileWriterUtil(String targetDir, OutputStreamCreator osc); File getFileToWrite(String packageName, String fileName); Writer getWriter(File fn, String encoding); Writer getWriter(String packageName, String fileName); Writer getWriter(String packageName, String fileName, String encoding); boolean isCollision(String packageName, String fileName); File buildDir(String packageName);  }### Answer:
@Test public void testGetFile() throws Exception { FileWriterUtil fileWriter = null; String tmpDir = System.getProperty("java.io.tmpdir"); File targetDir = new File(tmpDir + File.separator + "target"); try { targetDir.mkdirs(); fileWriter = new FileWriterUtil(targetDir.getAbsolutePath(), null); fileWriter.getWriter("com.iona.test", "A.java"); String packPath = "/com/iona/test/A.java".replace('/', File.separatorChar); String path = targetDir.getAbsolutePath() + packPath; assertNotNull(new File(path).getName()); } catch (IOException e) { e.printStackTrace(); } finally { cleanDir(targetDir); } }
@Test public void testGetWriter() throws Exception { FileWriterUtil fileWriter = null; String tmpDir = System.getProperty("java.io.tmpdir"); File targetDir = new File(tmpDir + File.separator + "target"); try { targetDir.mkdirs(); fileWriter = new FileWriterUtil(targetDir.getAbsolutePath(), null); assertNotNull(fileWriter.getWriter("com.iona.test.SAMPLE", "A.java")); } catch (IOException e) { e.printStackTrace(); } finally { cleanDir(targetDir); } }