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.splunk.shuttl.server.mbeans.JMXSplunkTest.java
public void _givenXmlConfFileWithValues_gettersReturnTheValuesConfigured() throws IOException { File confFile = createFile(); FileUtils.writeStringToFile(confFile, configurationWithTheTestFields); jmxSplunk = JMXSplunk.createWithConfFile(confFile); assertEquals(host, jmxSplunk.getHost()); assertEquals(port, jmxSplunk.getPort()); assertEquals(username, jmxSplunk.getUsername()); assertEquals(password, jmxSplunk.getPassword()); }
From source file:com.garethahealy.camel.file.loadbalancer.example1.routes.Read99FilesWithThreeReadersTest.java
@Override protected void doPreSetup() throws Exception { File directory = FileUtils.toFile(new URL("file:" + rootDirectory)); FileUtils.deleteDirectory(directory); directory.mkdir();/*from w w w. j a va 2 s . c o m*/ for (int i = 0; i < 99; i++) { FileUtils.writeStringToFile( FileUtils.toFile(new URL("file:" + rootDirectory + "/file" + Integer.toString(i) + ".log")), "file" + Integer.toString(i)); } LOG.info("Wrote files to: " + directory.getAbsolutePath()); }
From source file:com.cloud.servlet.StaticResourceServletTest.java
@Before public void setupFiles() throws IOException { rootDirectory = new File("target/tmp"); rootDirectory.mkdirs();// w w w . jav a2s.c o m final File webInf = new File(rootDirectory, "WEB-INF"); webInf.mkdirs(); final File dir = new File(rootDirectory, "dir"); dir.mkdirs(); final File indexHtml = new File(rootDirectory, "index.html"); indexHtml.createNewFile(); FileUtils.writeStringToFile(indexHtml, "index.html"); final File defaultCss = new File(rootDirectory, "default.css"); defaultCss.createNewFile(); final File defaultCssGziped = new File(rootDirectory, "default.css.gz"); defaultCssGziped.createNewFile(); }
From source file:de.tudarmstadt.ukp.dkpro.tc.crfsuite.writer.CRFSuiteDataWriter.java
@Override public void write(File aOutputDirectory, FeatureStore aFeatureStore, boolean aUseDenseInstances, String aLearningMode, boolean applyWeighting) throws Exception { writeFeatureFile(aFeatureStore, aOutputDirectory); Map<String, Integer> outcomeMapping = getOutcomeMapping(aFeatureStore.getUniqueOutcomes()); File mappingFile = new File(aOutputDirectory, CRFSuiteAdapter.getOutcomeMappingFilename()); FileUtils.writeStringToFile(mappingFile, outcomeMap2String(outcomeMapping)); }
From source file:com.galenframework.reports.HtmlReportBuilder.java
public void build(List<GalenTestInfo> tests, String reportFolderPath) throws IOException { makeSureReportFolderExists(reportFolderPath); JsonReportBuilder jsonBuilder = new JsonReportBuilder(); ReportOverview reportOverview = jsonBuilder.createReportOverview(tests); String overviewTemplate = IOUtils.toString(getClass().getResourceAsStream("/html-report/report.tpl.html")); String testReportTemplate = IOUtils .toString(getClass().getResourceAsStream("/html-report/report-test.tpl.html")); for (GalenTestAggregatedInfo aggregatedInfo : reportOverview.getTests()) { String testReportJson = jsonBuilder.exportTestReportToJsonString(aggregatedInfo); FileUtils.writeStringToFile( new File(reportFolderPath + File.separator + aggregatedInfo.getTestId() + ".html"), testReportTemplate.replace("##REPORT-TEST-NAME##", aggregatedInfo.getTestInfo().getName()) .replace("##REPORT-DATA##", testReportJson)); FileUtils.writeStringToFile(// www.ja v a2 s.c o m new File(reportFolderPath + File.separator + aggregatedInfo.getTestId() + ".json"), testReportJson); aggregatedInfo.getTestInfo().getReport().getFileStorage().copyAllFilesTo(new File(reportFolderPath)); } String overviewJson = jsonBuilder.exportReportOverviewToJsonAsString(reportOverview); FileUtils.writeStringToFile(new File(reportFolderPath + File.separator + "report.html"), overviewTemplate.replace("##REPORT-DATA##", overviewJson)); FileUtils.writeStringToFile(new File(reportFolderPath + File.separator + "report.json"), overviewJson); copyHtmlResources(reportFolderPath); }
From source file:com.exalttech.trex.stateful.utilities.FileManager.java
/** * @param data/* w w w.java2 s . c om*/ * @param file * @throws IOException */ public static void writeStringToFile(String data, File file) throws IOException { FileUtils.writeStringToFile(file, data); }
From source file:ch.systemsx.cisd.openbis.generic.shared.util.WebClientFilesUpdaterTest.java
@Override @BeforeMethod//from w w w.j a v a 2s . co m public void setUp() throws IOException { super.setUp(); openBISGwtXmlFile = new File(workingDirectory, WebClientFilesUpdater.OPENBIS_PACKAGE_NAME + "/" + WebClientFilesUpdater.OPENBIS_GWT_XML_FILE_NAME); FileUtils.writeStringToFile(openBISGwtXmlFile, OPENBIS_GWT_XML_FILE_CONTENT); assertTrue(openBISGwtXmlFile.exists()); clientPluginProviderJavaFile = new File(workingDirectory, WebClientFilesUpdater.CLIENT_PLUGIN_PROVIDER_CLASS.replace(".", "/") + ".java"); FileUtils.writeStringToFile(clientPluginProviderJavaFile, CLIENT_PLUGIN_PROVIDER_JAVA_FILE_CONTENT); assertTrue(clientPluginProviderJavaFile.exists()); final File pluginDir = new File(workingDirectory, WebClientFilesUpdater.OPENBIS_PACKAGE_NAME + "/" + WebClientFilesUpdater.PLUGIN_PACKAGE_NAME); assertTrue(pluginDir.mkdir()); assertTrue(new File(pluginDir, "demo").mkdir()); filesUpdater = new WebClientFilesUpdater(workingDirectory.getPath()); }
From source file:io.restassured.itest.java.FileUploadingITest.java
@Test public void can_upload_text_from_file() throws IOException { // Given/*from w w w . jav a 2s .co m*/ File file = folder.newFile("my.txt"); FileUtils.writeStringToFile(file, "Hello World"); // When given().contentType(ContentType.TEXT).body(file).when().post("/reflect").then().statusCode(200) .body(equalTo("Hello World")); }
From source file:net.itransformers.idiscover.v2.core.listeners.node.RawDataFileLogDiscoveryListener.java
@Override public void nodeDiscovered(NodeDiscoveryResult discoveryResult) { File baseDir = new File(projectPath, labelDirName); if (!baseDir.exists()) baseDir.mkdir();//from w w w .ja v a 2 s . c o m File rawDataDir = new File(baseDir, rawDataDirName); if (!rawDataDir.exists()) rawDataDir.mkdir(); String deviceName = discoveryResult.getNodeId(); File file = new File(rawDataDir, deviceName + ".xml"); if (discoveryResult.getDiscoveredData() != null) { if (discoveryResult.getDiscoveredData("rawData") != null) { String rawDataXml = new String((byte[]) discoveryResult.getDiscoveredData("rawData")); try { FileUtils.writeStringToFile(file, rawDataXml); } catch (IOException e) { logger.error(e); } } else { logger.info("no raw data found!!! in for " + discoveryResult.getNodeId()); } } else { logger.info("no Discovered data found!!! for " + discoveryResult.getNodeId()); } }
From source file:de.unidue.ltl.flextag.core.reports.TtAccuracyPerWordClassReport.java
public void execute() throws Exception { StorageService storageService = getContext().getStorageService(); for (TaskContextMetadata subcontext : getSubtasks()) { if (TcTaskTypeUtil.isMachineLearningAdapterTask(storageService, subcontext.getId())) { File locateKey = storageService.locateKey(subcontext.getId(), Constants.ID_OUTCOME_KEY); String report = generateWordClassReport(locateKey); File targetFile = storageService.locateKey(subcontext.getId(), OUTPUT_FILE); FileUtils.writeStringToFile(targetFile, report); }/* www. j av a2 s .com*/ } }