List of usage examples for org.apache.commons.io FileUtils writeStringToFile
public static void writeStringToFile(File file, String data) throws IOException
From source file:com.microsoft.applicationinsights.extensibility.initializer.docker.internal.FileFactory.java
public void create(String filePath, String data) throws IOException { FileUtils.writeStringToFile(new File(filePath), data); }
From source file:com.shazam.fork.pooling.geometry.GeometryCommandOutputLogger.java
@SuppressWarnings("ResultOfMethodCallIgnored") @Override//from ww w. jav a 2 s . c o m public void logCommandOutput(String deviceIdentifier, String commandOutput) throws IOException { strategyDir.mkdirs(); File file = new File(strategyDir, deviceIdentifier + "." + command.replaceAll("\\W+", "-") + ".txt"); FileUtils.writeStringToFile(file, commandOutput); }
From source file:ch.oakmountain.tpa.web.TpaWebPersistor.java
public static void createGraph(String name, String outputDir, IGraph graph, String htmlData) throws IOException { LOGGER.info("Creating graph " + name + "...."); String content = IOUtils.toString(TpaWebPersistor.class.getResourceAsStream("/graph-curved.html")); content = content.replaceAll(Pattern.quote("$CSVNAME$"), Matcher.quoteReplacement(name)) .replaceAll(Pattern.quote("$HTML$"), Matcher.quoteReplacement(htmlData)); FileUtils.writeStringToFile(Paths.get(outputDir + File.separator + name + ".html").toFile(), content); File file = new File(outputDir + File.separator + name + ".csv"); writeGraph(file, graph);//w ww. j a v a 2s . c o m TpaPersistorUtils.copyFromResourceToDir("d3.v3.js", outputDir); LOGGER.info("... created graph " + name + "."); }
From source file:com.predic8.membrane.examples.ProxiesXmlUtil.java
public void updateWith(String proxiesXmlContent, Process2 sl) throws IOException { SubstringWaitableConsoleEvent reloaded = new SubstringWaitableConsoleEvent(sl, "Spring Hot Deployment Thread started."); FileUtils.writeStringToFile(proxiesXml, proxiesXmlContent); reloaded.waitFor(10000);//from www . j av a 2s. c o m }
From source file:net.sourceforge.jweb.maven.minify.YUICompressorMinifier.java
public void minify(File f) { File saveTo = getSaveFile(f, ""); String parent = saveTo.getParent(); String pname = saveTo.getName().substring(0, saveTo.getName().indexOf(".")); String sname = saveTo.getName().substring(saveTo.getName().lastIndexOf(".")); String finalName = parent + File.separator + pname + this.getMinifyMojo().getMiniPrefix() + sname; File finalFile = new File(finalName); try {/* w ww.j a v a2s .c o m*/ FileUtils.writeStringToFile(finalFile, ""); String[] provied = this.getMinifyMojo().getYuiArguments(); int length = (provied == null ? 0 : provied.length); length += 5; int i = 0; String[] ret = new String[length]; ret[i++] = "--type"; ret[i++] = (saveTo.getName().toLowerCase().endsWith(".css") ? "css" : "js"); if (provied != null) { for (String s : provied) { ret[i++] = s; } } ret[i++] = f.getAbsolutePath(); ret[i++] = "-o"; ret[i++] = finalName; StringBuilder builder = new StringBuilder(); builder.append("yuicompressor "); for (String s : ret) { builder.append(s).append(" "); } this.getLog().debug(builder); YUICompressorNoExit.main(ret); } catch (Exception e) { //e.printStackTrace(); this.getLog().warn(e); this.getLog().info("minifier will copy source only"); try { FileUtils.copyFile(f, finalFile); } catch (IOException e1) { e1.printStackTrace(); } } }
From source file:edu.illinois.cs.cogcomp.nlp.corpusreaders.ereReader.CoNLL2002Writer.java
/** * Pass in the view, text annotation and the filename, it will produce the labels in the view to * a file named filename in CoNLL2003 format. * /*from w w w .j av a 2 s . co m*/ * @param view the view with the labels to produce. * @param ta the text annotation. * @param filename the filename output file name. * @throws IOException */ static public void writeViewInCoNLL2003Format(View view, TextAnnotation ta, String filename) throws IOException { String text = produceCoNLL2003Annotations(view, ta); FileUtils.writeStringToFile(new File(filename), text); }
From source file:com.igitras.codegen.common.utils.Utils.java
public static void writeFileInDirectory(String content, String fileName, File parentDirectory) { try {//from www . j a v a 2 s. c o m FileUtils.writeStringToFile(Utils.getChildFile(parentDirectory, fileName), content); } catch (IOException e) { } }
From source file:edu.harvard.iq.dataverse.ingest.IngestableDataCheckerTest.java
private File createTempFile(String filename, String fileContents) throws IOException { if (filename == null) { return null; }// w w w .j av a 2s.c om File fh = this.tempFolder.newFile(filename); fh.createNewFile(); if (fileContents != null) { FileUtils.writeStringToFile(fh, fileContents); } return fh; }
From source file:de.tudarmstadt.ukp.dkpro.core.io.graf.GrafReaderWriterTest.java
@Ignore("Doesn't work yet...") @Test/*from w w w. j a va 2 s .co m*/ public void test() throws Exception { String header = "<resourceHeader xmlns=\"http://www.xces.org/ns/GrAF/1.0/\">\n" + " <resourceDesc>\n" + " <annotationSpaces>\n" + " <annotationSpace xml:id=\"pos\" pid=\"http://dummy1/\"/>\n" + " <annotationSpace xml:id=\"type\" pid=\"http://dummy2/\"/>\n" + " </annotationSpaces>\n" + " </resourceDesc>\n" + "</resourceHeader>"; FileUtils.writeStringToFile(new File("target/header.xml"), header); testRoundTrip(GrafReader.class, GrafWriter.class, "reference/example1.txt.xml"); }
From source file:com.cloud.utils.ProcessUtilTest.java
@Test public void pidCheck() throws ConfigurationException, IOException { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); FileUtils.writeStringToFile(pidFile, "123456\n"); ProcessUtil.pidCheck(pidFile.getParent(), pidFile.getName()); String pidStr = FileUtils.readFileToString(pidFile); Assert.assertFalse("pid can not be blank", pidStr.isEmpty()); int pid = Integer.parseInt(pidStr.trim()); int maxPid = Integer.parseInt(FileUtils.readFileToString(new File("/proc/sys/kernel/pid_max")).trim()); Assert.assertTrue(pid <= maxPid); }