List of usage examples for org.apache.commons.io FileUtils writeStringToFile
public static void writeStringToFile(File file, String data, String encoding) throws IOException
From source file:cms.service.account.HTMLAllPageManager.java
private void saveJs(String outLinkStr, String htmlName) { htmlFileMsg += "|" + htmlName;//?? //System.out.println(":"+outLinkStr +" ??:"+htmlName); String src = "<script language=\"javascript\" type=\"text/javascript\"> " + "window.location.href='" + outLinkStr + "'</script>"; File file = new File(this.getClass().getResource("/").getPath() + "../../html/" + htmlName); //System.out.println(file.getPath()); try {/*from w ww. j ava2 s .com*/ FileUtils.writeStringToFile(file, src, "UTF-8"); } catch (IOException e) { e.printStackTrace(); } }
From source file:core.Operator.java
public void toFile() { String appWrite = "#oName#" + name + "#oFunc#" + func + "#oPhone#" + tel + "#oMail#" + mail + "#oSek#" + sektion;//from w w w . j a v a2 s .c o m try { FileUtils.writeStringToFile(new File("Operators\\" + func + " _ " + name + ".asdp"), appWrite, "utf-8"); // " } catch (Exception e) { } }
From source file:com.intuit.karate.demo.controller.UploadController.java
@PostMapping public @ResponseBody FileInfo upload(@RequestParam("file") MultipartFile multipartFile, @RequestParam String name) throws Exception { String uuid = UUID.randomUUID().toString(); String filePath = FILES_BASE + uuid; FileUtils.copyToFile(multipartFile.getInputStream(), new File(filePath)); FileUtils.writeStringToFile(new File(filePath + "_meta.txt"), name, "utf-8"); return new FileInfo(uuid, name); }
From source file:com.thoughtworks.go.helper.SvnRemoteRepository.java
public void addUser(String username, String password) throws Exception { enableAuthentication();/* ww w.jav a 2s.com*/ File passwdFile = new File(repo.projectRepositoryRoot(), "conf/passwd"); String passwd = String.join(FileUtil.lineSeparator(), Files.readAllLines(passwdFile.toPath())); if (!(passwd.contains("\n[users]\n"))) { passwd = passwd + "\n[users]\n"; } passwd = passwd + String.format("\n%s = %s\n", username, password); FileUtils.writeStringToFile(passwdFile, passwd, UTF_8); }
From source file:com.thoughtworks.go.server.service.RailsAssetsServiceTest.java
@Test public void shouldGetAssetPathFromManifestJson() throws IOException { FileUtils.writeStringToFile(new File(assetsDir, ".sprockets-manifest-digest.json"), json, UTF_8); when(context.getInitParameter("rails.root")).thenReturn(""); when(context.getRealPath(any(String.class))).thenReturn(assetsDir.getAbsolutePath()); railsAssetsService.initialize();//w w w .ja v a 2s.c o m assertThat(railsAssetsService.getAssetPath("application.js"), is("assets/application-bfdbd4fff63b0cd45c50ce7a79fe0f53.js")); assertThat(railsAssetsService.getAssetPath("junk.js"), is(nullValue())); }
From source file:com.thoughtworks.go.remote.work.artifact.PluggableArtifactMetadata.java
private void writeMetadataFile(File pluggableArtifactMetadataFolder, String pluginId, Map<String, Map> responseMetadata) { if (responseMetadata == null || responseMetadata.isEmpty()) { LOGGER.info(String.format("No metadata to write for plugin `%s`.", pluginId)); return;// ww w . j a v a2s .co m } try { LOGGER.info(String.format("Writing metadata file for plugin `%s`.", pluginId)); FileUtils.writeStringToFile(new File(pluggableArtifactMetadataFolder, format("%s.json", pluginId)), new Gson().toJson(responseMetadata), StandardCharsets.UTF_8); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:core.Applicant.java
public void saveToFile() { String appWrite = "#sgName#" + comp + "#pName#" + name + "#pPosition#" + func + "#pPhone#" + tel + "#pMail#" + mail + "#pBank#" + bank + "#pKonto#" + clrnr + "THISISADELIMITERTROLOLOLOLOLOL" + acnr; try {//from ww w . j a v a 2 s. c o m FileUtils.writeStringToFile(new File("applicants\\" + comp + " - " + name + ".asdp"), appWrite, "utf-8"); // " } catch (Exception e) { } }
From source file:com.gargoylesoftware.htmlunit.javascript.host.URLTest.java
/** * @throws Exception if the test fails//from ww w . ja v a 2 s . c o m */ @Test @NotYetImplemented public void createObjectURL() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head><title>foo</title>\n" + "<script>\n" + "function test() {\n" + " if (document.testForm.fileupload.files) {\n" + " var files = document.testForm.fileupload.files;\n" + " var url = window.URL.createObjectURL(files[0]);\n" + " alert(url);\n" + " window.URL.revokeObjectURL(url);\n" + " }\n" + "}\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <form name='testForm'>\n" + " <input type='file' id='fileupload' name='fileupload'>\n" + " </form>\n" + " <button id='testBtn' onclick='test()'>Tester</button>\n" + "</body>\n" + "</html>"; final WebDriver driver = loadPage2(html); final File tstFile = File.createTempFile("HtmlUnitUploadTest", ".txt"); try { FileUtils.writeStringToFile(tstFile, "Hello HtmlUnit", TextUtil.DEFAULT_CHARSET); final String path = tstFile.getCanonicalPath(); driver.findElement(By.name("fileupload")).sendKeys(path); driver.findElement(By.id("testBtn")).click(); final String url = getCollectedAlerts(driver).get(0); Assert.assertTrue(url, url.startsWith("blob:")); } finally { FileUtils.deleteQuietly(tstFile); } }
From source file:jsentvar.GenerateTestsResults.java
public void jsonReaderResult() throws IOException { String possFile = "resources/text_doc0.json"; JsonReader jreader = new JsonReader(); HashMap<String, HashMap<Integer, Integer>> poss = jreader.reader(possFile); System.out.println(poss.toString()); FileUtils.writeStringToFile(new File("resources/test/doc0Result.txt"), poss.toString(), "utf8"); }
From source file:energy.usef.environment.tool.util.FileUtil.java
public static void writeTextToFile(String filename, String data) throws IOException { FileUtils.writeStringToFile(new File(filename), data, DEFAULT_CHARSET); }