List of usage examples for java.io File createTempFile
public static File createTempFile(String prefix, String suffix) throws IOException
From source file:eu.planets_project.tb.impl.serialization.ExperimentFileCache.java
/** * //from ww w . j a v a2 s .com */ public ExperimentFileCache() { if (cachedir != null) return; // Generate a temporary file and turn it into a directory: try { UUID dirname = UUID.randomUUID(); File tmp = File.createTempFile(dirname.toString(), cacheExt); tmp.delete(); tmp.mkdir(); tmp.deleteOnExit(); cachedir = tmp; log.info("Set up export cache: " + cachedir.getPath()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:cosmos.results.integration.CosmosIntegrationTest.java
@BeforeClass public static void createAccumuloCluster() throws Exception { macDir = File.createTempFile("miniaccumulocluster", null); Assert.assertTrue(macDir.delete());/* www. ja v a2 s .com*/ Assert.assertTrue(macDir.mkdir()); macDir.deleteOnExit(); MiniAccumuloConfig config = new MiniAccumuloConfig(macDir, ""); config.setNumTservers(2); mac = new MiniAccumuloCluster(config); mac.start(); ZooKeeperInstance zkInst = new ZooKeeperInstance(mac.getInstanceName(), mac.getZooKeepers()); Connector c = zkInst.getConnector("root", new PasswordToken("")); // Add in auths for "en" c.securityOperations().changeUserAuthorizations("root", new Authorizations("en")); zk = new TestingServer(); }
From source file:gov.nih.nci.cabig.caaers.service.adverseevent.AdditionalInformationDocumentServiceIntegrationTest.java
@Override protected void setUp() throws Exception { super.setUp(); file = File.createTempFile(RandomStringUtils.randomAlphabetic(4), ".txt"); FileUtils.writeStringToFile(file, "sample text"); additionalInformationDocumentService = (AdditionalInformationDocumentService) getDeployedApplicationContext() .getBean("additionalInformationDocumentService"); expeditedAdverseEventReportDao = (ExpeditedAdverseEventReportDao) getDeployedApplicationContext() .getBean("expeditedAdverseEventReportDao"); ExpeditedAdverseEventReport expeditedAdverseEventReport = expeditedAdverseEventReportDao.getById(-1); additionalInformation = expeditedAdverseEventReport.getAdditionalInformation(); }
From source file:com.stratio.ingestion.morphline.commons.CalculatorTest.java
protected Config parse(String file, Config... overrides) throws IOException { File tmpFile = File.createTempFile("morphlines_", ".conf"); IOUtils.copy(getClass().getResourceAsStream(file), new FileOutputStream(tmpFile)); Config config = new Compiler().parse(tmpFile, overrides); config = config.getConfigList("morphlines").get(0); Preconditions.checkNotNull(config);/* w ww . ja v a2s.co m*/ return config; }
From source file:edu.uci.ics.hyracks.algebricks.core.algebra.prettyprint.PlanPlotter.java
public static void printOptimizedLogicalPlan(ILogicalPlan plan) throws AlgebricksException { int indent = 5; StringBuilder out = new StringBuilder(); int randomInt = 10000 + randomGenerator.nextInt(100); appendln(out, "digraph G {"); for (Mutable<ILogicalOperator> root : plan.getRoots()) { printVisualizationGraph((AbstractLogicalOperator) root.getValue(), indent, out, "", randomInt); }//from w ww .j a va2s .co m appendln(out, "\n}\n}"); try { File file = File.createTempFile("logicalOptimizedPlan", ".txt"); FileUtils.writeStringToFile(file, out.toString()); file.deleteOnExit(); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.sf.taverna.raven.helloworld.HelloWorld.java
public void run(PrintStream out) throws IOException { File tmpFile = File.createTempFile("helloworld", "test"); tmpFile.deleteOnExit();/* w ww . ja va2s . c o m*/ FileUtils.writeStringToFile(tmpFile, TEST_DATA, "utf8"); String read = FileUtils.readFileToString(tmpFile, "utf8"); out.print(read); }
From source file:com.talis.inject.guice.PropertiesConfiguredModuleFactoryTest.java
@Test public void readPropertiesFromFileSpecifiedBySystemProperty() throws Exception { File tmpFile = File.createTempFile("injector-module", ".properties"); tmpFile.deleteOnExit();//from w w w . j a va2s.c om FileUtils.writeStringToFile(tmpFile, String.format("%s=%s", PropertiesConfiguredModuleFactory.MODULE_PROPERTY, TestModuleThree.class.getName())); System.clearProperty(PropertiesConfiguredModuleFactory.PROPERTIES_LOCATION_PROP); try { System.setProperty(PropertiesConfiguredModuleFactory.PROPERTIES_LOCATION_PROP, tmpFile.getAbsolutePath()); Module[] modules = new PropertiesConfiguredModuleFactory().getModules(); assertEquals(1, modules.length); assertTrue(TestModuleThree.class.isInstance(modules[0])); } finally { System.clearProperty(PropertiesConfiguredModuleFactory.PROPERTIES_LOCATION_PROP); } }
From source file:com.stimulus.archiva.domain.Settings.java
public static void saveProperties(final String name, String intro, Settings prop, String charset) throws ConfigurationException { File f = null;//from www. jav a 2 s . com try { // if the disk is full we dont want to end up in a situation where we delete // server.conf file f = File.createTempFile("server_conf", ".tmp"); prop.store(intro, new FileOutputStream(f), charset); } catch (Exception e) { if (f != null) f.delete(); throw new ConfigurationException("failed to save properties. cause:" + e.toString(), e, logger); } File newFile = new File(name); newFile.delete(); //Mod start Seolhwa.kim 2017-04-13 //f.renameTo(newFile); try { logger.debug("####################################### Call Files.move"); Files.move(Paths.get(f.getAbsolutePath()), Paths.get(newFile.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { // TODO Auto-generated catch block logger.debug("####################################### Call Files.move fails"); e.printStackTrace(); } //Mod end Seolhwa.kim 2017-04-13 }
From source file:com.netflix.config.DynamicURLConfigurationTestWithFileURL.java
@Test public void testFileURLWithPropertiesUpdatedDynamically() throws IOException, InterruptedException { File file = File.createTempFile("DynamicURLConfigurationTestWithFileURL", "testFileURLWithPropertiesUpdatedDynamically"); populateFile(file, "test.host=12312,123213", "test.host1=13212"); AbstractConfiguration.setDefaultListDelimiter(','); DynamicURLConfiguration config = new DynamicURLConfiguration(0, 500, false, file.toURI().toString()); Thread.sleep(1000);// ww w . j a va 2 s . c o m Assert.assertEquals(13212, config.getInt("test.host1")); Thread.sleep(1000); populateFile(file, "test.host=12312,123213", "test.host1=13212"); populateFile(file, "test.host=12312,123213", "test.host1=13212"); CopyOnWriteArrayList writeList = new CopyOnWriteArrayList(); writeList.add("12312"); writeList.add("123213"); config.setProperty("sample.domain", "google,yahoo"); Assert.assertEquals(writeList, config.getProperty("test.host")); }
From source file:com.bt.aloha.testing.SimpleSipStackLogEnhancerTest.java
@Before public void before() throws Exception { tempSourceFile = File.createTempFile("log-enhancer-source", ".txt"); tempTargetFile = File.createTempFile("log-enhancer-target", ".html"); tempSourceFile.deleteOnExit();//w ww.j ava2 s .c om tempTargetFile.deleteOnExit(); }