TempFileGenerator { public static File generate(String fileContent) { File file = null; try { String tempDir = getTempDir(); file = new File(tempDir, getRandomFileName()); Files.write(fileContent, file, Charset.defaultCharset()); } catch (IOException e) { logger.error("generate temp file failed!", e); } return file; }  static File generate(String fileContent);  }
@Test public void testGenerate() throws Exception { File file = TempFileGenerator.generate("xxx"); Assert.notNull(file); }