@Test public void testCreateFile() throws IOException { String fileContent = "Hello Junit Test."; String directory = "de/kissmda/test"; String fileName = "readme.txt"; Context context = mock(Context.class); when(context.getTargetModel()).thenReturn( "target/generated-test-sources/resources"); fileWriter.createFile(context, directory, fileName, fileContent); verify(context).getTargetModel(); }
public void createFile(final Context context, final String directory, final String fileName, final String fileContent) throws IOException { String directoryToBeCreated = context.getTargetModel() + File.separator + directory; new File(directoryToBeCreated).mkdirs(); Writer writer = null; try { File file = new File(directoryToBeCreated + File.separator + fileName); if (context.getTargetEncoding() != null) { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), context.getTargetEncoding())); } else { writer = new BufferedWriter(new java.io.FileWriter(file)); } writer.write(fileContent); } finally { if (writer != null) { writer.close(); } } }
FileWriter { public void createFile(final Context context, final String directory, final String fileName, final String fileContent) throws IOException { String directoryToBeCreated = context.getTargetModel() + File.separator + directory; new File(directoryToBeCreated).mkdirs(); Writer writer = null; try { File file = new File(directoryToBeCreated + File.separator + fileName); if (context.getTargetEncoding() != null) { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), context.getTargetEncoding())); } else { writer = new BufferedWriter(new java.io.FileWriter(file)); } writer.write(fileContent); } finally { if (writer != null) { writer.close(); } } } }
FileWriter { public void createFile(final Context context, final String directory, final String fileName, final String fileContent) throws IOException { String directoryToBeCreated = context.getTargetModel() + File.separator + directory; new File(directoryToBeCreated).mkdirs(); Writer writer = null; try { File file = new File(directoryToBeCreated + File.separator + fileName); if (context.getTargetEncoding() != null) { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), context.getTargetEncoding())); } else { writer = new BufferedWriter(new java.io.FileWriter(file)); } writer.write(fileContent); } finally { if (writer != null) { writer.close(); } } }  }
FileWriter { public void createFile(final Context context, final String directory, final String fileName, final String fileContent) throws IOException { String directoryToBeCreated = context.getTargetModel() + File.separator + directory; new File(directoryToBeCreated).mkdirs(); Writer writer = null; try { File file = new File(directoryToBeCreated + File.separator + fileName); if (context.getTargetEncoding() != null) { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), context.getTargetEncoding())); } else { writer = new BufferedWriter(new java.io.FileWriter(file)); } writer.write(fileContent); } finally { if (writer != null) { writer.close(); } } }  void createFile(final Context context, final String directory, final String fileName,
			final String fileContent); }
FileWriter { public void createFile(final Context context, final String directory, final String fileName, final String fileContent) throws IOException { String directoryToBeCreated = context.getTargetModel() + File.separator + directory; new File(directoryToBeCreated).mkdirs(); Writer writer = null; try { File file = new File(directoryToBeCreated + File.separator + fileName); if (context.getTargetEncoding() != null) { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), context.getTargetEncoding())); } else { writer = new BufferedWriter(new java.io.FileWriter(file)); } writer.write(fileContent); } finally { if (writer != null) { writer.close(); } } }  void createFile(final Context context, final String directory, final String fileName,
			final String fileContent);  }