List of usage examples for java.io File createTempFile
public static File createTempFile(String prefix, String suffix) throws IOException
From source file:jenkins.plugins.livingdoc.ReportCollectorTest.java
@BeforeClass public static void initBaseDir() throws IOException, URISyntaxException { URL dirUrl = ReportCollectorTest.class.getResource("ReportCollector"); baseDir = new File(dirUrl.toURI()); File localBuildDir = File.createTempFile("junit", "builddir"); FileUtils.deleteQuietly(localBuildDir); FileUtils.forceMkdir(localBuildDir); buildDir = new FilePath(localBuildDir); }
From source file:eu.scape_project.pc.droid.DroidIdentificationTest.java
/** * Set up.//from w w w .ja v a 2 s. co m * @throws Exception */ @BeforeClass public static void setUpClass() throws Exception { URL sigFileV67Url = new URL(SIGNATURE_FILE_V67_URL); InputStream sigFileStream = sigFileV67Url.openStream(); File tmpSigFile = File.createTempFile("tmpsigfile", ".xml"); FileOutputStream fos = new FileOutputStream(tmpSigFile); IOUtils.copy(sigFileStream, fos); fos.close(); dihj = DroidIdentification.getInstance(tmpSigFile.getAbsolutePath()); }
From source file:cz.pichlik.goodsentiment.common.CSVWriter.java
public CSVWriter(String... header) { CSVFormat format = CSVFormats.format(header); try {/* w w w . j a v a 2 s.c om*/ this.temporaryResultFile = File.createTempFile("temp", "csv"); } catch (IOException e) { throw new RuntimeException("Cannot create a temp file for merging CSV files", e); } try { csvPrinter = new CSVPrinter(new FileWriter(this.temporaryResultFile), format); } catch (IOException e) { throw new RuntimeException("Cannot initialize the CSV printer", e); } }
From source file:com.amazon.dtasdk.v2.signature.CredentialStoreTest.java
@BeforeClass public static void setUp() throws IOException { VALID_FILE = File.createTempFile("store", "csv"); FileWriter writer = new FileWriter(VALID_FILE); writer.write(String.format("%s %s\n", KEYS[0], KEYS[1])); // Intentionally check if blank lines are supported writer.write(String.format("%s %s\n\n", KEYS[2], KEYS[3])); writer.write(String.format("%s %s\n", KEYS[4], KEYS[5])); writer.write("\n"); writer.close();/*from ww w .j a v a2s. c o m*/ INVALID_FILE = File.createTempFile("store", "csv"); writer = new FileWriter(INVALID_FILE); writer.write(String.format("%s%s\n", KEYS[0], KEYS[1])); writer.write(String.format("%s %s\n", KEYS[2], KEYS[3])); writer.write(String.format("%s %s\n", KEYS[4], KEYS[5])); writer.write("\n"); writer.close(); }
From source file:com.epam.jaxb.XMLExternalEntityExpansionTest.java
@BeforeClass public static void beforeTests() throws IOException { xxeFile = File.createTempFile("xxeTests", "txt"); xxeFile.deleteOnExit();//from www . j a v a2 s .com FileUtils.write(xxeFile, "xxeAttackSuccessful"); }
From source file:edu.unc.lib.dl.util.ZipFileUtil.java
/** * Create a temporary directory, unzip the contents of the given zip file to * it, and return the directory./*from w w w. j av a 2 s. c o m*/ * * If anything goes wrong during this process, clean up the temporary * directory and throw an exception. */ public static File unzipToTemp(File zipFile) throws IOException { // get a temporary directory to work with File tempDir = File.createTempFile("ingest", null); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); log.info("Unzipping to temporary directory: " + tempDir.getPath()); try { unzip(new FileInputStream(zipFile), tempDir); return tempDir; } catch (IOException e) { // attempt cleanup, then re-throw org.apache.commons.io.FileUtils.deleteDirectory(tempDir); throw e; } }
From source file:ch.unibas.fittingwizard.infrastructure.base.VmdRunner.java
public static boolean isAvailable() { File vmdScript = null;// w w w. ja v a2 s .c om try { // create temporary file to exit vmd vmdScript = File.createTempFile("vmd", ".vmd"); FileUtils.write(vmdScript, "exit"); VmdRunner runner = new VmdRunner(); int retval = runner.exec(Arrays.asList("-dispdev", "none", "-e", vmdScript.getAbsolutePath())); if (retval == 0) { logger.info("Vmd found in path."); return true; } else { logger.warn("Vmd not found in path."); return false; } } catch (Exception e) { logger.warn("Vmd not found in path.", e); return false; } finally { if (vmdScript != null) { vmdScript.delete(); } } }
From source file:com.stratio.connector.cassandra.CCMHandler.java
/** * Start a test Cassandra cluster to execute the unit tests. The method creates a * temporal file with the contents of {@code /com/stratio/meta/test/test.sh} and proceeds * with its execution.//from w ww . j a v a2 s . c om */ public static void startCCM() { BufferedReader in = null; try { File tempFile = File.createTempFile("stratio-start-ccm", ".sh"); InputStream resourceStream = CCMHandler.class .getResourceAsStream("/com/stratio/connector/cassandra/test.sh"); FileUtils.copyInputStreamToFile(resourceStream, tempFile); tempFile.setExecutable(true); Process p = Runtime.getRuntime().exec(tempFile.getAbsolutePath()); in = new BufferedReader(new InputStreamReader(p.getInputStream(), Charset.forName("UTF-8"))); String line; while ((line = in.readLine()) != null) { LOG.debug(line); } FileUtils.forceDeleteOnExit(tempFile); } catch (IOException e) { LOG.error("Error starting CCM", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.error("IO exception closing ccm output.", e); } } } }
From source file:eu.scape_project.pc.droid.DroidIdentificationTaskTest.java
/** * Set up.//from w ww . j a v a 2 s . com * @throws Exception */ @BeforeClass public static void setUpClass() throws Exception { URL sigFileV67Url = new URL(SIGNATURE_FILE_V67_URL); InputStream sigFileStream = sigFileV67Url.openStream(); File tmpSigFile = File.createTempFile("tmpsigfile", ".xml"); FileOutputStream fos = new FileOutputStream(tmpSigFile); IOUtils.copy(sigFileStream, fos); fos.close(); dihj = DroidIdentificationTask.getInstance(tmpSigFile.getAbsolutePath()); }
From source file:brut.androlib.mod.SmaliMod.java
public static boolean assembleSmaliFile(InputStream is, DexBuilder dexBuilder, boolean verboseErrors, boolean printTokens, File smaliFile) throws IOException, RecognitionException { // copy our filestream into a tmp file, so we don't overwrite File tmp = File.createTempFile("BRUT", ".bak"); tmp.deleteOnExit();/*from w w w .ja v a 2s . co m*/ OutputStream os = new FileOutputStream(tmp); IOUtils.copy(is, os); os.close(); return assembleSmaliFile(tmp, dexBuilder, verboseErrors, printTokens); }